对于c/c++ to中的file-io,是否有标准的跨平台模拟?
int open(const char *pathname, int flags, mode_t mode);发布于 2013-08-27 18:12:59
int open(const char *pathname, int flags, mode_t mode)不是C++。它是纯C语言。
您应该使用std::fstream ( http://www.cplusplus.com/reference/fstream/fstream/ )
#include <fstream>
int main () {
std::fstream fs;
fs.open ("test.txt", std::fstream::in | std::fstream::out | std::fstream::app);
fs << " more lorem ipsum";
fs.close();
return 0;
}发布于 2013-08-27 19:54:28
文件描述符不是跨平台的,它们属于POSIX标准,所以它们只能在类似Linux/Unix的系统上工作。
https://stackoverflow.com/questions/18462270
复制相似问题