#include<stdio.h>
int main()
{
FILE *opening;
opening = fopen("hello.usr","w");
fprintf(opening,"Hello world!");
fclose(opening);
printf("Writing to the file was successful.\n");
printf("Closing the program");
return 0;
}
我试过用这段代码在 C 编程中创建一个文件并写入文本“Hello world!”在里面。这段代码有什么问题?
最佳答案
如果你想知道哪里出了问题,请检查 fopen
opening = fopen("hello.usr","w");
if (opening == NULL) {
perror("fopen");
}
关于c语言创建一个文件,在文件中写上hello world,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37989919/