当前位置: 代码迷 >> C语言 >> 如何扩展内存呢?
  详细解决方案

如何扩展内存呢?

热度:97   发布时间:2008-01-20 13:23:06.0
如何扩展内存呢?
不知道要输入多少字符
先扩展内存  然后输入   不知道怎么实现???
搜索更多相关的解决方案: 内存  字符  输入  

----------------解决方案--------------------------------------------------------
嘿!!!
#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();
}
----------------解决方案--------------------------------------------------------
  相关解决方案