PDA

View Full Version : problem with getting data with atEnd



ramin.lich
29th September 2014, 21:57
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

ChrisW67
29th September 2014, 22:34
You should be using QTextStream::atEnd() or you risk losing the QTextStream internal buffer.