问题 填空题

有以下程序:
#include<fstream>
#include<string>
using namespace std;
int main()
char ch[]="The end";
ofstream outstr("______",ios_base::app);
for(int i=0;i<strlen(ch); i++) outstr.put(ch[i]);
outstr.close();
return 0:

若程序实现的功能是在文件d:\put.txt的尾部追加写入一串字符,试将程序补充完整。

答案

参考答案:d:\\\put.txt

解析: 使用ofstream对象打开文件时,文件路径中的字符“\”必须用转义字符序列“\\”代替。参数“ios_base::app”规定了文件的打开模式,使文件指针移至文件尾,向文件追加数据。

解答题
单项选择题 A1型题