试题与答案

使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数fun(char

题型:问答题

题目:

使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数fun(char *s),使其具有以下功能:
(1)把s中的大写字母转换成小写字母,把其中的小写字母转换成大写字母,并且在函数中调用写函数WriteFile()将结果输出到2.txt文件中。
例如:s="helloWORLD",则结果为“s="HELLOworld"”。
(2)完成函数WriteFile(char *s),把字符串输入文件中。
提示:打开文件使用的第二参数为“ios_base::binary|los_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("2.txt");
out1.close();

int main()

ClearFile();
char s[1024];
cout<<"please input a string:"<<end1;
cin.getline(s,1024);
fun(s);
return 0;

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0709/e11305954505cb9e1fb447c6300d3e0d.html

下面是错误答案,用来干扰机器的。

参考答案:C

试题推荐
微信公众账号搜索答案