请问这个要怎么解决?编写一个 C 程序,它接受 3 个参数:一个文件名,整数范围的开始,以及整数范围的结尾;并创建一个包含指定整数的具有此名称的文件。如果给定的参数数量错误,或者无法创建文件,程序应该打印适当的错误消息。下面有机翻,还有一个示例供参考。
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *output_stream = fopen("hello.txt", "w");
if (output_stream == NULL) {
perror("hello.txt");
return 1;
}
fprintf(output_stream, "Hello, Andrew!\n");
// fclose will flush data to file
// best to close file ASAP
// but doesn't matter as file autoamtically closed on exit
fclose(output_stream);
return 0;
}