473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

not to read the data from buffer line by line

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?
Expand|Select|Wrap|Line Numbers
  1. while(1)
  2. {
  3. char buffer[SIZE];
  4.         int bytes_read = gzread (f, buffer, SIZE - 1);
  5.  buffer[bytes_read] = '\0';
  6. line = strtok_r(strdup(buffer), "\n", &next_line);
  7. while(line)
  8.         {
  9.       line  = strtok_r(NULL, "\n", &next_line);
  10.         cout << line << endl;
  11.    }
  12. if (bytes_read < SIZE - 1)
  13. {
  14. break;
  15. }
  16. }
  17.  
Jun 27 '14 #1
3 1447
weaknessforcats
9,208 Expert Mod 8TB
Can you not just unpack the .gz archive into text files and use cin.getline to read your strings?
Jun 27 '14 #2
The file is pretty huge and unpacking it will take too much disk space.
Jun 28 '14 #3
weaknessforcats
9,208 Expert Mod 8TB
How much space would that be?

Otherwise, you will have to write .gz decompressor.
Jun 28 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: jenny | last post by:
Hi, I have a java socket program running on AIX 4.3.3.0 platform. It opens a socket and sends data to our customer over a leased fractional T1 line. The line is always connected. However,...
13
by: j. del | last post by:
I am just beginning to write programs... and my first task that I have set myself is to write a little program that will generate cryptic bywords from a source of text. A cryptic byword is...
3
by: tvn007 | last post by:
I wrote the code below to read data from file into structure using C. However, I would like to convert it to C++. Could someone please give me some hints. I am not that famaliar with C++ Thanks...
0
by: Aryeh Holzer | last post by:
Hi, I've been trying to use the weather webservice available from the National Weather Service (NWS), at http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML. wsdl without success. Here's...
4
by: Josema | last post by:
Hi to all, Im searching a hand to solve an Exception that i get when i try to give the user to a gmail account... Any help would be appreciated.. Thanks in advance This is a piece of my...
0
by: quocvuong2005 | last post by:
Hi all ! I have a webservice that contains a Helloworld() method (This return a string type ) and a asp.net application . I call Helloworld method from webservice , it works fine . but when i call...
0
by: quocvuong2005 | last post by:
Hi all ! I have a webservice that contains a Helloworld() method (This return a string type ) and a asp.net application . I call Helloworld method from webservice , it works fine . but when i call...
5
by: Arno | last post by:
reposted with the right microsoft managed newsgroup ID: Sorry for the inconvinience Hi, I've written a class for client-socket connection, but I get a lot of times the error message "Unable...
6
by: Kinbote | last post by:
Hi, I'm trying to make a function that opens a file, reads it in line by line, puts each line into an malloc'd array, and returns the array. I suspect I'm going about it in an atypical fashion, as...
4
by: Waqas Danish | last post by:
Hello, I am using standard socket functions to send and receive data on a client/server model. I am using K-Develop under Ubuntu 10.04 OS. The application works fine locally but when I deploy it...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.