Your OS doesn't like the path: "D://out.txt"
So use QFile file("D:/out.txt"); //it works on windows too
Also you say to the compiler your main function returns an int, so put that to use:
#include <QtCore/QCoreApplication>
#include<QTextStream>
#include<QFile>
int main()
{
QFile file("D:/out.txt");
return 1; //return 1 in case the file can't be opened
out << "The magic number is: " << 49 << "\n";
file.close();
return 0; //returns 0 if everything executed
}
#include <QtCore/QCoreApplication>
#include<QTextStream>
#include<QFile>
int main()
{
QFile file("D:/out.txt");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return 1; //return 1 in case the file can't be opened
QTextStream out(&file);
out << "The magic number is: " << 49 << "\n";
file.close();
return 0; //returns 0 if everything executed
}
To copy to clipboard, switch view to plain text mode
Bookmarks