我试图让用户输入他们想要我读取的输入文件,我想将一个输入保存到两个变量中,输入文件将是" file.txt&#34 ;,但我希望输出文件是" file.txt.cvt"
目前我遇到了问题。
这就是我所拥有的
printf("Enter file name: "); //asks for filename from user
scanf("%s %s.cvt", input_file, output_file); //stores string as "filename"
inputf = fopen(input_file, "r"); /*file open stored string as
read only. 'filename, "r"'*/
outputf = fopen(output_file, "w");
答案 0 :(得分:1)
strcpy(output_file, input_file); // Make a copy of the input file name
strcat(output_file, ".cvt"); // Add the ".cvt" suffix to it