Computer Science Canada writing to a binary file |
Author: | stkmtd [ Mon Aug 24, 2009 4:57 pm ] | ||||
Post subject: | writing to a binary file | ||||
Ahoy, having some trouble writing binary to a file. I'm just trying to write a simple program (as an exercise) that will output a file so that when I open it in a hex editor it will contain the value 0xDEADBEEF. My code is as follows:
When I compile at the shell (with g++):
I'm new to C++, so any help is appreciated. |
Author: | DemonWasp [ Mon Aug 24, 2009 6:39 pm ] | ||
Post subject: | RE:writing to a binary file | ||
The compiler seems to be looking at your code and seeing "pointer to a char", not "an array of char". This alternate syntax compiles (though I haven't bothered testing it...):
|
Author: | stkmtd [ Mon Aug 24, 2009 7:30 pm ] |
Post subject: | RE:writing to a binary file |
Hoorah. It works. Thank you kindly. |