为何不用QFile QTextStream QFile data("output.txt"); if (data.open(QFile::WriteOnly | QFile::Truncate)) { QTextStream out(&data); out << "Result: " << qSetFieldWidth(10) << left << 3.14 << 2.7; // writes "Result: 3.14 2.7 " }
QFile data("output.txt"); if (data.open(QFile::WriteOnly | QFile::Truncate)) { QTextStream out(&data); out << "Result: " << qSetFieldWidth(10) << left << 3.14 << 2.7; // writes "Result: 3.14 2.7 " }
1、你的加上using namespace std看看; 2、Qt的话还是推荐用它本身的文件处理,参考http://qt.csdn.net/articles.aspx?pointid=216&pointid2=6 [quote=引用 楼主 u013291805 的回复:] Qt 5.2 程序开头有 #include <fstream> 但调试时错误。 ofstream fout("a.txt"); 错误信息: 'ofstream' was not declared in this scope
Qt 5.2 程序开头有 #include <fstream> 但调试时错误。 ofstream fout("a.txt"); 错误信息: 'ofstream' was not declared in this scope
24,860
社区成员
27,333
社区内容
加载中
试试用AI创作助手写篇文章吧