Create stream from file : QTextStream « Qt « C++






Create stream from file

  


#include <QFile>
#include <QTextStream>


int main()
{
    QFile file("out.txt");
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return 1;

    QTextStream out(&file);
    out << "The magic number is: " << 49 << "\n";
}

   
    
  








Related examples in the same category

1.Output string with QTextStream
2.Using QTextStream to read a text file
3.Read text file QTextStream
4.Read QTextStream line by line