0

Ok this comes as two questions: what is the best variable for storing bianary data and how would I send That through a XOR gate? When I searched it didn't really do anything because XOR is a binary operator. I remember how to open o file in binary form from my last post on it. My preveous post on XOR was for text based and is not of any revalance to this.0

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by mzimmers
0

I know the operators n' stuff and how to use it with simple stuff; I want to use it with fstream in binary mode.

0
ostream& write ( const char* s , streamsize n );

This will put it into a character array. If you associate the array with a union of numeric data types, you can then manipulate it mathematically and/or logically.

0

What? Could you explain that a little more and where I would put the stuff to open it in binary fform sorry, its a little confusing.

0

OK. Let's say that you want to read four bytes in at a time, and access them as a 32-bit integer. (You can adjust this for your needs; I'm keeping the example as simple as possible.)

- Create a union of a 4-character array, and an int32_t.
- do a stream.read() of four characters, using the character array in the union above
- access the read data using the int32_t in the union above

There may be other/better ways to do this, but this is what I use.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.