Open binary file for write-operation : QFile « Qt « C++






Open binary file for write-operation

  

#include <QFile>
#include <QTextStream>


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

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

   
    
  








Related examples in the same category

1.Create QFile from file path
2.Create file with QFile
3.Open QFile with WriteOnly flag
4.Output with QFile
5.Check file existance and file name with QFile
6.Open a text file in read-only mode
7.Read file till file end
8.Read text file line by line
9.Read byte array from text file
10.Open text file for write-operation