I have spent all the day but I'm unable to create a stream buffer and 'play' with it.
I want to have a i-o stream based on a known size buffer.
Later I want to put and get data, like if it was a file, but it isn't a file.
Please, can anybody help me?
Where to start ? Cplusplus reference is a good place but I dont see how to begin...
Thanks
Hello computergeek.
I wish you help me.
My questions about this theme (buffers, streams, etc) are related around this problem:
I want to 'play' with data, fill my char [] buffer and then write/read form disk.
How can I use this char[] buffer like a file ? That is to say, I want to use seek, put,get,>>,<<, etc.
If I have this char[] buffer, is there a way to use as 'stream' ? How?
I remember that with Java was easy.
You seem to be over complicating things. The beginning of an array is always '0', as for the end of the array I suggest setting it's size with an integer you can reference later. Something like this:
1 2 3 4 5
constint X = 10; /*Variable to set the size of the array*/
char array[X];
/* that way later on you can do cool stuff without thinking about the size of your array */
for(int i = 0; i <= X; ++i)
{/*Do something with array[i] */}
See if we had set the size of array to '10' by writing char array[10]; we would have to change it in every place we go threw the array. Now we change 'X' and everything knows the size of 'array[]'.
I dont know If all is because my bad english.... (nobody understand my need)
Imagine I have to store a float, 3 doubles, 1 string , and other 2 floats into a char array.
How can I do this ?
This is because I'm praying to find something similar to a 'memorystream'....
Do you understand me now ?
Thanks for your patience
uff.
I'm going to explain it again.
You know the features of fstream ok?
Well, then I want to have a similar object (a memory stream buffer, if it can be called so) to get and put data, but to-from memory, not to-from disk.
I think the basic iostream can be my object, but I dont know how to create and use it.
My typical work could be:
I write data (any kind of data:1 float, 3 doubles, 1 string, 1 char [], etc ) to my 'buffer'. When it reaches the size I want I save it to a file (or maybe I send to another computer). Then I will read it.
Using Java streams I can do it. Why not with c++
I hope you understand me now.
Thanks