Nominate our 2022 Qt Champions!

End of The File With atEnd

  • hi all
    this is my prog

    @ QCoreApplication a(argc, argv);
    QString path("e:\digi.txt");
    QFileInfo info(path);

    int x;
    int *b;
    b=new int;
    QFile ready(path);;
    QTextStream point(&ready);
    int k;

    now this code wont print latest data in the text file but will print the first data in the text file why?

  • Moderators

    If you want to read a binary file, use QDataStream. Since you seem to be opening a text file, however, you should open it with QFile::Text flag in addition to QFile::ReadOnly.

    I suggest first reading the data into a QString to see what is being read, then translate it to an integer.

  • Hi..Use|QIODevice::Truncate);//at line 9

    hope it helps

Log in to reply