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); ready.open(QIODevice::ReadOnly); QTextStream point(&ready); while(!ready.atEnd()){ point>>x; } ready.close(); int k; k=info.size(); qDebug()<<x;@
now this code wont print latest data in the text file but will print the first data in the text file why?
thanks -
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.