问题 填空题

执行如下程序后的输出结果是 【15】 。 #include <iostream> #include <fstream> using namespace std; int main ( ) {char s[25];ofstream fl("data.txt");f1<<"C++ Programming";f1.close ();ifstream f2 ("data.txt");if (f2.good()) f2>>s;f2.close();cout<<s;return 0; }

答案

参考答案:C++

解析: 程序先在当前目录下建立一个data文本文件,并写入“C++ Programming”。然后打开该文件,将其中的数据输入到变量s中,由于采用提取符“>>”读时遇到空格终止,所以最后字符数组s中存放的是“C++”。

填空题
单项选择题