timmu
30th December 2011, 06:21
Hi,
I'm trying to use QFile to open a text file (floating numbers in a single column) and read the numbers. The example below won't even compile, something is wrong with it but I don't know what.
QFile INfile("example1.txt");
if(!INfile.open(QIODevice::ReadOnly | QIODevice::Text)) {exit(1);}
float numb;
while (!INfile.atEnd())
{
INfile >> numb;
cout << numb << "\n";
}
INfile.close();
Thanks
I'm trying to use QFile to open a text file (floating numbers in a single column) and read the numbers. The example below won't even compile, something is wrong with it but I don't know what.
QFile INfile("example1.txt");
if(!INfile.open(QIODevice::ReadOnly | QIODevice::Text)) {exit(1);}
float numb;
while (!INfile.atEnd())
{
INfile >> numb;
cout << numb << "\n";
}
INfile.close();
Thanks