【发布时间】:2016-01-08 07:36:44
【问题描述】:
我希望能够创建一个文件,然后将文本写入其中,但我不知道该怎么做。 这是我的一段代码:
FILE *note;
char name[100], *content;
printf("Write the name of your file.\n");
scanf("%s", &name);
note=fopen(name, "w");
printf("Write the content of your file\n");
接下来我该怎么做?
【问题讨论】:
-
请在 fopen 等故障点后添加错误处理(可以返回 null )。之后 google fwrite
-
或许别的页面会告诉你怎么做作业
-
scanf("%s", name);中的 strings 不需要&运算符