starrl
18th May 2006, 04:34
I am having problems with the following short program I wrote with Qt 4.1.2
#include <QString>
#include <iostream>
#include <QProcess>
using namespace std;
void ProcessLine( QString );
int main()
{
QProcess *gzip = new QProcess;
QString line;
gzip->start("gunzip in.txt.gz -c");
while (gzip->waitForReadyRead()) {
while (gzip->canReadLine()) {
line = gzip->readLine();
ProcessLine( line );
}
}
}
void ProcessLine( QString line ) {
cout << line.toStdString();
}
my test file in.txt.gz contains the following all zipped
this is a test 1
this is a test 2
this is a test 3
this is a test 4
this is a test 5
this is a test 6
this is a test 7
this is a test 8
when I compile and run my code I get the following output.
this is a test 2
this is a test 3
this is a test 4
this is a test 5
this is a test 6
this is a test 7
this is a test 8
Notice that I have somehow lost the first line of the file.
every once in a while I do end up getting the first line.
Can someone Please tell me what's happing to the first line?
What is wrong with my code?
#include <QString>
#include <iostream>
#include <QProcess>
using namespace std;
void ProcessLine( QString );
int main()
{
QProcess *gzip = new QProcess;
QString line;
gzip->start("gunzip in.txt.gz -c");
while (gzip->waitForReadyRead()) {
while (gzip->canReadLine()) {
line = gzip->readLine();
ProcessLine( line );
}
}
}
void ProcessLine( QString line ) {
cout << line.toStdString();
}
my test file in.txt.gz contains the following all zipped
this is a test 1
this is a test 2
this is a test 3
this is a test 4
this is a test 5
this is a test 6
this is a test 7
this is a test 8
when I compile and run my code I get the following output.
this is a test 2
this is a test 3
this is a test 4
this is a test 5
this is a test 6
this is a test 7
this is a test 8
Notice that I have somehow lost the first line of the file.
every once in a while I do end up getting the first line.
Can someone Please tell me what's happing to the first line?
What is wrong with my code?