Accessing text file contents
-
Hi,
I am reading a text file by using the following codeQFile inputFile("cotdr.txt");
inputFile.open(QIODevice::ReadOnly);
QTextStream in(&inputFile);
QString line = in.readAll();
inputFile.close();the text file contains the numbers like
6789,1234,4567,7890,9845
4567,7890,1234,4523,6789
3467,4304,2411,1111,2321now I want to compare 6789 & 4567 and keep the maximum number(6789) and compare the kept number(6789) with 3467 and return the maximum number of each row
finally I have to get an output file with maximum numbers 6789,7890,4567,7890,9845 also viceversacould some one please suggest me how could I do that?
an example code helps me a lot using c++
please hope someone knows about how to do that, i am eager to see the reply
thanks heaps -
@ while (!file.atEnd()) {
QByteArray line = file.readLine();
QList<QByteArray> numbers = line.split(',')
for(QString numstr:numbers)
{
int num = numstr.toInt();
.....
}
}@ -
Thanks for your reply, but when i complied it says doesn't support for loop in cpp.
alos.i have one more question is there any possibility that i can setup qbytearray line as a two dimensional array
how can compare when i have line numbers indexed with rows in qlist
i need to compare the columns