vs2010中编写C++程序 怎么打开文件

2025-05-23 19:35:26
推荐回答(1个)
回答(1):

使用 fstream
需要
using
namespace
std;
。。
要判断是否打开成功可以这样。。
fstream
filestr;
filestr.open
("test.txt");
if
(filestr.is_open())
{
filestr
<<
"File
successfully
open";
filestr.close();
}
else
{
cout
<<
"Error
opening
file";
}