问题
填空题
有以下程序:
#include <fstream>
#include <string>
using namespace std;
int main ()
char ch[] = "The end";
ofstream outstr( "d:\\put.txt", ios_base: :app);
for (int i = 0; i < strlen( ch ); i++ )
outstr.put(ch[i]);
outstr.close();
return 0;
程序实现的功能是 【15】 。
答案
参考答案:在文件put.txt的尾部追加写入一串字符
解析: 解本题的关键是要了解文件打开模式常量ios_base::app的含义。常量ios base::app表示为添加数据而打开文件(总是在文件尾部写),因此上述程序实现的功能就是在文件尾部写入数组ch中字符串。