Hello,
I wish to know how to read numbers from a file and store them in something like a vector.
My file is a .txt with numbers in rows and columns:
12 34 567 423 788
23 343 45 56 67 78
...
I've already been able to read the file using:
if(!myFile.
open(QFile::ReadOnly)) {
qDebug() << "Cannot open...";
return;
}
line = input.readLine();
qDebug() << line;
QFile myFile(file);
if(!myFile.open(QFile::ReadOnly))
{
qDebug() << "Cannot open...";
return;
}
QTextStream input(&myFile);
QString line;
line = input.readLine();
qDebug() << line;
To copy to clipboard, switch view to plain text mode
It displays correctly the line of my file.
Now, I need to store each numerical value of the file to a vector or similar, so I can do operations over those numbers.
Something like:
int VectorFirstLine[5];
qDebug() << VectorFirstLine[3];
VectorFirstLine[5]*AnotherVariable;
int VectorFirstLine[5];
qDebug() << VectorFirstLine[3];
VectorFirstLine[5]*AnotherVariable;
To copy to clipboard, switch view to plain text mode
And so on... What is the best way to do that? Using a QtList? a QVector?
Thank you very much!
Bookmarks