views:

83

answers:

1

I have the following simple code:

ofstream output("test");
output << 'a';

When I do an octal dump of the file, I get this:

0000000 000141
0000001

I can see that 000141 (in base 8) is 8 bits wide and 0000001 is probably EOF. What is the first byte of all 0's and why is it there? I know it is null is ascii but what is its purpose?

+1  A: 

This has nothing to do with C++ (except the source code that shows we've got a file of length 1 with an 'a' in it), you probably should've tagged this linux or hexdump, because it looks to me like the output of the linux tool hd/hexdump using octal output.

See this Wikipedia article for more information.

EDIT: Ah, I missed the question title. So it's od, the octal "brother" of hd.

The first column shows the file offsets (7 digits, hex), just like James said. If the file would be longer, it'd be more obvious.

schnaader