【发布时间】:2012-10-20 03:55:57
【问题描述】:
#include<stdio.h>
int main()
{
char *arg[10],*c;
int count=0;
FILE *fp,*fq;
printf("Name of the file:");
scanf("%s",arg[1]);
fp=fopen(arg[1],"w");
printf("\t\t%s",arg[1]);
printf("Input the text into the file\n");
printf("Press Ctrl+d to the stop\n");
while((*c=getchar())!=EOF)
{
fwrite(c,sizeof(char),1,fp);
count++;
}
return 0;
}
【问题讨论】:
-
家庭作业?如果是就没有问题。只需标记它,以便您获得更好的答案
-
你至少可以自己写点东西
-
如果您所做的只是邮政编码,您真的应该去codereview.stackexchange.com
-
至少在你的帖子中写一些东西让我们知道你的问题是什么,而不是让我们假设你想知道它为什么会出现段错误。
-
旁注:学习使用调试器。至少足以找出引发错误的行(对于 linux 上的 gcc,这将是
gdb program \n run \n [wait until it stops] bt \n,其他系统会有所不同,但仍然具有此功能)。那么您可能已经自己弄清楚了,并且可以向我们展示更短、更清晰的示例代码。