int x = 5; cout<<(char)x;
the code above outputs an int x in raw binary, but only 1 byte. what I need it to do is output the x as 4-bytes in
You can use the std::ostream::write() member function:
std::ostream::write()
std::cout.write(reinterpret_cast(&x), sizeof x);
Note that you would usually want to do this with a stream that has been opened in binary mode.