Possible Duplicate:
How to make cout behave as in binary mode?
I am using C++ to print binary data to the stdout and then I redirect it to a file.
(I do not want to write directly to a file).
However, when I try to print the value '0A'
I am getting '0D 0A'
. (this is what I see when I copy the output to HexEdit).
From what I can figure out, '0A'
is the ascii for 'new line' so cout automatically adds the '0D'
which is 'carriage return'.
What I want is to print 0A
alone. how can I do this?
my code:
unsigned char *buf = new unsigned char[width+1];
for (int x = 0; x < width; x++)
{
buf[x] = (unsigned char) src[x];
}
buf[width] = '\0'
cout<<buf;
I've seen this: Print new line to a text file without carriage return (CR) in windows but it does not seem to help me.