Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!bloom-beacon!apple!oliveb!pyramid!lll-winken!uunet!hodge!jdm From: jdm@hodge.UUCP (jdm) Newsgroups: comp.lang.c Subject: printf() problem Keywords: C printf Message-ID: <11657@hodge.UUCP> Date: 26 Apr 89 00:25:48 GMT Organization: Hodge Computer Research Corporation Lines: 37 Perhaps someone could explain this printf() phenomena to me. I have a file with binary data. I want to read four consecutive bytes from the file and display them with printf(). The data in in the file in hex is: 92 AB 4E 33 I fopen() the file in binary mode and used the following line of code to read and print out the data: printf("%x %x %x %x\n", getc(fp), getc(fp), getc(fp), getc(fp)); Although the order of the data in the file is: 92 AB 4E 33 printf() displays it as: 33 4E AB 92 Just the reverse of its order in the file. Changing the code to: a = getc(fp); b = getc(fp); c = getc(fp); d = getc(fp); printf("%x %x %x %x\n", a, b, c, d); solves the problem, but why did printf() screw the order up when I used getc() directly? How might I correct this? This happens in both Turbo C 2.0 and MS C 5.1.