关于ofstream文件流的有关问题
关于ofstream文件流的问题C/C++ codebool OpenFileForWrite(){outfile.clear()outfile.open(filePath.c_s
关于ofstream文件流的问题
C/C++ codebool OpenFileForWrite() { outfile.clear(); outfile.open(filePath.c_str(),std::ostream::out|std::ostream::binary); if (!outfile) { return false; } return true; }
这段代码,outfile始终是false, filePath是string类型,里面是一个文件的全路径信息,是不是open的第一个参数只能是文件名???那如果我想创建特定路径下的文件怎么办???
还有个问题,如果我stringstream中有一些数据,我如何写入到outfile中呢???
[解决办法]