问答题 使用VC6打开 下的源程序文件modi2.cpp。请完成函数fun(char*s),该函数完成以下功能:
(1)把s中的大写字母转换成小写字母,把其中的小写字母转换成大写字母。并且在函数中调用写函数WriteFile()将结果输出到modi2.txt文件中。
例如:s="helloTEST",则结果为:s="HELLOtest"
(2)完成函数WriteFile(char*s),把字符串输入文件中。提示:打开文件使用的第二参数为ios_base::binary|ios_base::app。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
#include<iostream>
#include<fstream>
#include<cmath>
using namespace std;
void WriteFile(char*s)
{
}
void fun(char*s)
{
}
void ClearFile()
{
ofstream out1;
out1.open("modi2.txt");
out1.ciose();
}
int main()
{
ClearFile();
char s[1024];
【正确答案】
【答案解析】(1)voidWriteFile(char*s)中的命令语句:
ofstream out1;
out1.open("modi2.txt",los_base::binary|ios_base::app); //打开文件modi2
out1