After the loop, you just multiply the count integer with the amount of bytes read per read call (probably 1? ;))
I'm not sure if it is better or worse, but I like this method much more:
stream.seekp(0, std::ios::end); // find eof
size_t size = stream.tellp(); // this actually provides the real size
stream.seekp(0); // find start
char* buffer = new char[size]; // allocate space
stream.read(buffer, size); // read it all in at once
stream.close(); // done :D
Note: seekp and tellp may be seekg and tellg.
Can't remember whether p or g version is for ifstream.
Actually, I'm reading in 1024 byte chunks, and sending the 1024 bit buffer over winsock each read, so I need a way to communicate how many characters the last buffer actually holds, if not the entire 1024 bytes
I have to go with Ancient though...I tried using tellg(),but tellg() reads -1 once you have read past the end of the file, because it returns the next char that will be read, not the last one that was read, which of course doesn't exist after EOF =(
thanks again, gcount() is exactly what I needed =)
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...