所以,我有这段代码:
#include <stdio.h>
int main(int argc, char *argv[]){
FILE *ReadFile, *WriteFile;
float key;
int quantKeys,T;
int i;
/* errors verification */
if (argc < 3){
printf(" Use the correct entry parameters.\n");
exit(1);
}
if((ReadFile = fopen(argv[1],"rw")) == NULL){
printf("Error when trying to open the file\n");
exit(1);
}
if((WriteFile = fopen(argv[2],"rw")) == NULL){
printf("Error when trying to open the file.\n");
exit(1);
}
/* main code */
quantKeys = 45658;
T = 5;
fprintf(WriteFile,"%d",T);
fprintf(WriteFile,"%d",quantKeys);
fclose(ReadFile);
fclose(WriteFile);
return 0;
}
我想做的就是写变量&#34; quantChaves&#34;和&#34; T&#34;在一个文本文件中,我作为main函数的第三个参数传递。它编译并运行没有问题,但我的文本文件在运行后保持为空。 我做错了什么?