简单的文件I/O问题
#include <stdio.h>
#define MAX_BUF 1024
int main(void)
{
char *inputstr;
char *outputstr;
FILE *fp;
printf("input string:");
scanf("%s",inputstr);
fp=fopen("file.test","a+b");
fputs(inputstr,fp);
outputstr=fgets(outputstr,MAX_BUF,fp);
fclose(fp);
exit(0);
}
编译成功,但是执行出错。出错信息为:Segmentation fault
如果加上:printf("%s",outputstr);
就显示:(null)Aborted
还有个问题:怎么用gcc step by step debug程序?