First let me start by saying I am new to C. My program needs to read in a character in binary(including non-printable characters) and then display the character in octal representation, like the 'od' program does in UNIX. My code is as follows:
The two program results are as follows:Code:int c; FILE *Fp; Fp = fopen(argv[1], "rb"); while((c = fgetc(Fp)) != EOF) { fprintf(stdout, "%06ho\t", c); } fclose(Fp);
"%06ho" was given to me for formatting purposes, so I know that is correct.[solaris]$ myod test
000150 000145 000154 000154 000157 000040 000167 000157 000162 000154 000144 000012
[solaris]$ od test
0000000 064145 066154 067440 073557 071154 062012
0000014
I'll admit, I don't really understand...basically typing "myod test" should perform the same function as typing "od test", where test is a binary file.
Thanks for your help.