GESP C++ 真题 · 逐题精解
首页C++四级真题 › 2025年12月 › 第14题

GESP 2025年12月 C++四级 单选题 第14题

C++四级单选题2025年12月第14题

所属知识点:综合应用(跨题型) 难度要求:掌握 考频:—

执行下面 C++ 程序,会输出( )。
int main() {
ofstream fout("test.txt");
fout << "Happy" << endl;
fout << "New Year";
fout.close();
ifstream fin("test.txt");
string s1, s2;
fin >> s1;
getline(fin, s2);
fin.close();
cout << s1 << "|" << s2;
return 0;
}

正确答案:D

题目解析

文件为 "Happy\nNew Year"。fin>>s1 读到 "Happ………

完整解析为会员内容二级及以上的逐题精讲需开通 VIP。一级解析全部免费。前往 GESPPASS 解锁

想系统刷完 GESP C++ 1~8 级真题,并查看每道题的逐题精讲?

进入 GESPPASS 开始练习