Works fine:
#include <QtCore>
#include <QDebug>
int main(int argc, char *argv[])
{
outFile->write("See, it does get out!\n");
outFile->close();
}
delete outFile;
inFile->close();
qDebug() << line;
}
delete inFile;
return 0;
}
#include <QtCore>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QFile *outFile = new QFile("out.txt");
if (outFile->open(QIODevice::WriteOnly)) {
outFile->write("See, it does get out!\n");
outFile->close();
}
delete outFile;
QFile *inFile = new QFile("out.txt");
if (inFile->open(QIODevice::ReadOnly)) {
QByteArray line = inFile->readLine();
inFile->close();
qDebug() << line;
}
delete inFile;
return 0;
}
To copy to clipboard, switch view to plain text mode
gives
"See, it does get out!
"
"See, it does get out!
"
To copy to clipboard, switch view to plain text mode
So, the question becomes what are you doing wrong? Are you attempting to write a file somewhere you do not have permission (e.g. under Program Files on Windows)? Are you not writing or reading the file you think you are?
Bookmarks