题库 C++/C语言题库 题目列表 下面哪种方式不能实现将字符串"Welcome to GESP!...
单选题

下面哪种方式不能实现将字符串"Welcome to GESP!"输出重定向到文件log.txt ( )。

A.

1 freopen("log.txt", "w", stdout); 
2 cout << "Welcome to GESP!" << endl; 
3 fclose(stdout);
B.

1 std::ofstream outFile("log.txt"); 
2 outFile << "Welcome to GESP!" << endl; 
3 outFile.close();
C.

1 std::ofstream outFile("log.txt"); 
2 cout << "Welcome to GESP!" << endl; 
3 outFile.close();
D.

1 ofstream log_file("log.txt"); 
2 streambuf* org_cout = cout.rdbuf(); 
3 cout.rdbuf(log_file.rdbuf()); 
4 cout << "This output will go to the log file." << endl; 
5 cout.rdbuf(oorg_cout);
题目信息
2024年 四级 选择题
-
正确率
0
评论
32
点击