I'm reading strings one after another and trying to split it using strtok_r. This doesnot seem to be working Is there any way around this?
I have a .gz file from which I'm reading the data into the buffer in chunks.
The below code works fine only for the first chunk on data. Later it just breaks out.
Can any1 helpme with this?
I have a .gz file from which I'm reading the data into the buffer in chunks.
The below code works fine only for the first chunk on data. Later it just breaks out.
Can any1 helpme with this?
Code:
while(1)
{
char buffer[SIZE];
int bytes_read = gzread (f, buffer, SIZE - 1);
buffer[bytes_read] = '\0';
line = strtok_r(strdup(buffer), "\n", &next_line);
while(line)
{
line = strtok_r(NULL, "\n", &next_line);
cout << line << endl;
}
if (bytes_read < SIZE - 1)
{
break;
}
}
Comment