2016-03-27 60 views
0

我想要求用户键入他们想要我读取的输入文件,并且我想将一个输入保存到两个变量中,其中输入文件将是“file.txt “,但我希望输出文件为”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"); 
+1

只要有用户输入源文件规范,然后使用的strcpy和strcat的,其额外的扩展位汇编输出文件规范。 –

回答

1
strcpy(output_file, input_file); // Make a copy of the input file name 
strcat(output_file, ".cvt"); // Add the ".cvt" suffix to it