Page 1 of 1

A simple way to copy raw bytes in files in C++

Posted: Tue Dec 25, 2007 12:32 am
by earlz
Ok, I am fairly new to iostreams, and this is just starting to get annoying...
I can't figure out how the crap to just copy one byte out of the file and into an array..

I can't figure out a way to get the total file size of the stream, or to read a single character *easily*

I mean, their is the get(), but that does formatting, and can be complicated with raw binary files, I don't need formatting, I just need the raw bytes!

Re: A simple way to copy raw bytes in files in C++

Posted: Tue Dec 25, 2007 2:45 am
by bluecode
hckr83 wrote:I can't figure out a way to get the total file size of the stream [...]
Seek to the end with seekg and then get the get pointer position with tellg.
I mean, their is the get(), but that does formatting.
It does not, see here. There is also a read function.