fscanf函数返回值的问题
#include<stdio.h>#include<stdlib.h>
int main()
{
char *s;
while(fscanf(stdin,"%s",s)!=EOF)
{
printf("%s\n",s);
}
return 0;
}
我是想连续输入字符串并且输出,直到ctrl+d结束。请教一下我这么写为什么不行。谢谢大家

程序代码:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i = 0;
char *pn = NULL, *p = calloc(1, sizeof(char));
if(!p) exit(0);
while((*(p + i) = getchar()) != EOF) {
pn = realloc(p, (i + 2) * sizeof(char));
if(!pn) exit(0);
*(pn + i) = *(p + i);
*(pn + ++i) = '\0';
p = pn;
}
puts(p);
free(p);
return 0;
}
