fstream file(file_1.c_str(), ios::out | ios::in | ios::ate); //convert string to const char*
如果文件不存在则出错 . if ( ! file ) = true
fstream file(file_1.c_str(), ios::out | ios::in | ios::app); //convert string to const char*
使用 ios::app
seekg
& seekp
函数不起作用 . file.seekg(4, ios_base::beg);
我想拥有:
-
USER输入文件名
-
如果NON存在则创建文件
-
使用seekg&seekp;
-
如果再次运行程序,则不删除该文件 .
1 回答
如果我理解正确,你需要这样的东西: