which data structure can I use?

V

vesper_carmen

Hi,

I am getting data from a server over the network using a HTTP request
The data comes in chunks that I currently appending to a file I have
opened earler for read. Later I read it out line by line from this file
using the getline function.
I have no means of knowing how big the data will be beforehand. But, I
was to use an in memory data structure instead of the file that will
let the read the data out line by line, exactly as I did wth the file.
Can someone help me with this? A char array wouldnt work as how do I
get the data out line by line? Thats absolutely essential to me,

Thanks,
Carmen
 
A

Alan Johnson

Hi,

I am getting data from a server over the network using a HTTP request
The data comes in chunks that I currently appending to a file I have
opened earler for read. Later I read it out line by line from this file
using the getline function.
I have no means of knowing how big the data will be beforehand. But, I
was to use an in memory data structure instead of the file that will
let the read the data out line by line, exactly as I did wth the file.
Can someone help me with this? A char array wouldnt work as how do I
get the data out line by line? Thats absolutely essential to me,

Thanks,
Carmen

Use a stringstream, ostringstream, or istringstream. They are declared
in the standard header <sstream>, and work essentially like fstream,
ofstream, and ifstream, respectively.

-Alan
 
M

Maxim Yegorushkin

I am getting data from a server over the network using a HTTP request
The data comes in chunks that I currently appending to a file I have
opened earler for read. Later I read it out line by line from this file
using the getline function.
I have no means of knowing how big the data will be beforehand. But, I
was to use an in memory data structure instead of the file that will
let the read the data out line by line, exactly as I did wth the file.
Can someone help me with this? A char array wouldnt work as how do I
get the data out line by line? Thats absolutely essential to me,

Just search the array for "\r\n" which designates the end of line.

You could also take a look at libevent library that has a buffer data
structure which takes the burden of reading a socket/file off you and
allows you to extract lines easily.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top