如何扩展内存呢?
不知道要输入多少字符先扩展内存 然后输入 不知道怎么实现???
----------------解决方案--------------------------------------------------------
嘿!!!
#include "stdio.h"void main(void)
{
struct ch
{
char x;
struct ch *next;
}*a,*head,*end;
int n;
for(n=0;;a++)
{
a=(struct ch *)malloc(sizeof(struct ch));
scanf("%c",a->x);
if(n==0)head=end=a;
if(n!=0)
{end->next=a;
end=a;
end->next=NULL;
}
}
end=head;
while(end->next==NULL)
{printf("%c",end->x);
end=end->next;
}
getch();
}
----------------解决方案--------------------------------------------------------
楼上的不错,帮你顶一个。。。。
----------------解决方案--------------------------------------------------------
回复 2# 的帖子
太感激了 我仔细研究下 ----------------解决方案--------------------------------------------------------
回复 2# 的帖子
#include "stdio.h"void main(void)
{
struct ch
{
char x;
struct ch *next;
}*a,*head,*end;
int n;
for(n=0;;a++) //是for(n=0;;n++) 吧
{
a=(struct ch *)malloc(sizeof(struct ch));
scanf("%c",a->x);
if(n==0)head=end=a;
if(n!=0)
{end->next=a;
end=a;
end->next=NULL;
}
}
end=head;
while(end->next==NULL)
{printf("%c",end->x);
end=end->next;
}
getch();
}
----------------解决方案--------------------------------------------------------