Computer Science Canada Binary reading |
Author: | Ktomislav [ Sat Feb 14, 2009 12:41 pm ] |
Post subject: | Binary reading |
Is it possible to read file bit by bit to boolean? |
Author: | wtd [ Sat Feb 14, 2009 1:19 pm ] |
Post subject: | RE:Binary reading |
You can read in individual bytes, then use bit-wise operators to access the individual bits. |
Author: | Ktomislav [ Sat Feb 14, 2009 3:15 pm ] | ||
Post subject: | Re: Binary reading | ||
Can I do it like this?
And could you please explain me why do I have to use ios::ate and ios::beg instead of nothing or just ios::beg? |
Author: | btiffin [ Sun Feb 15, 2009 12:05 am ] | ||
Post subject: | RE:Binary reading | ||
ios::ate will seek to end on open, so then ios::beg will be required to seek back to the beginning. If you don't set ate, you won't need the seek to beginning. If you have something like
should work. The fine control provided by the I/O stream flags and manipulators requires a fair level of understanding for optimal use. http://www.cplusplus.com/doc/tutorial/files.html is a good read. Cheers Edit; yeah, more typos |
Author: | Ktomislav [ Sun Feb 15, 2009 8:28 am ] | ||
Post subject: | Re: RE:Binary reading | ||
btiffin @ 15.2.2009, 06:05 wrote:
should work. I know, but it doesn't work. Never mind, I figured out what I needed and thank you for replying. |