Xref: news2.mv.net comp.os.msdos.djgpp:1241 From: bmm AT bmm DOT pc DOT cs DOT cmu DOT edu (Bruce Maggs) Newsgroups: comp.os.msdos.djgpp Subject: fgetc Date: 15 Feb 1996 22:19:53 GMT Organization: Carnegie-Mellon University, School of Computer Science Lines: 50 Message-ID: Reply-To: bmm+@cs.cmu.edu NNTP-Posting-Host: bmm.pc.cs.cmu.edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi, The function getc seems to be skipping over bytes with value 13 (a.k.a. \r and carriage return). In particular, the following program, when compiled with djgpp version 1.12maint4, seems to never print out a value of 13, even when there are bytes with value 13 in the first 265 bytes of the input stream: #include #include int main(void){ int i; char buf; for (i = 0; i<265; i++){ buf = getc(stdin); printf("%d ",buf); } } I compiled it as follows: gcc -c test.c -o test.o gcc -o test test.o coff2exe test I compiled it under gcc on my Sun Sparc ELC workstation running SunOS, as follows: gcc test.c I ran the program on the same input, first as test < sun.gif (on my PC) and then as a.out < sun.gif (on my Sun) The output from the Sun is shown below. The output from the PC is the same, except that the 13 that lies between 25 and 111 does not appear. getchar and fgetc do the same thing. Any possible explanations? Thanks. Bruce Maggs 71 73 70 56 57 97 15 0 15 0 -60 0 0 -1 -1 -1 -1 -1 -50 -1 -1 -100 -1 -1 99 -1 -1 49 -1 -1 0 -1 -50 -100 -1 -50 99 -1 -50 49 -1 -50 0 -50 -50 -50 -50 -50 -100 -50 -50 99 -50 -50 49 -50 -50 0 -50 -100 99 -50 -100 49 -50 -100 0 -67 -67 -67 -83 -83 -83 -100 -100 -100 -100 -100 49 -100 -100 0 -100 99 49 -100 99 0 -116 -116 -116 99 99 0 99 49 0 0 0 0 0 0 0 0 0 0 0 0 0 33 -7 4 1 0 0 10 0 44 0 0 0 0 15 0 15 0 0 5 -125 -96 34 74 20 -44 36 -56 35 73 98 59 85 81 -108 -96 4 -62 -80 34 117 89 50 125 12 -121 3 75 82 -63 68 28 40 -96 -64 48 24 44 20 25 13 111 -122 80 46 5 -121 -59 69 99 68 34 14 -126 -128 24 -72 -64 72 123 85 -80 97 57 64 104 -72 22 100 109 -80 102 34 16 102 -52 20 117 32 -4 -18 8 91 103 72 40 -128 8 5 15 81 112 71 51 9 5 -115 19 10 91 27 122 49 72 -105 16 34 19 102 112 60 49 17 16 -111 -102 21 27 111 122 122 21 -94 45 36 23 121 21 25 56 10 33 0 59 -1 -1 -1