From: Robert Neinast Newsgroups: comp.os.msdos.djgpp Subject: Can't Even Read File Correctly Message-ID: X-Newsreader: MicroPlanet Gravity v2.50 Lines: 59 Date: Thu, 08 Nov 2001 17:56:18 GMT NNTP-Posting-Host: 12.87.149.37 X-Complaints-To: abuse AT worldnet DOT att DOT net X-Trace: bgtnsc06-news.ops.worldnet.att.net 1005242178 12.87.149.37 (Thu, 08 Nov 2001 17:56:18 GMT) NNTP-Posting-Date: Thu, 08 Nov 2001 17:56:18 GMT Organization: AT&T Worldnet To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com This is driving me nuts. In C, I'm doing simple getchars from stdin and writing to a file, and it keeps getting truncated. Anybody have any ideas what the heck I'm doing wrong???? (I have 15 years experience with C programming, so either I am doing something incredibly stupid, or something weird is going on.) This is on Windows 98, djgpp 2.03. My file (nnn.c) is =============================== #include main(argc, argv) int argc; char *argv[]; { int c; FILE *fp; if ((fp = fopen("xx.aa", "wb"))==NULL) { fprintf(stderr, "could not open output file\n"); exit(1); } while ((c=getchar())!=EOF) { putc(c, fp); } fclose(fp); exit(0); } =============================== $ ls -l -rw-r--r-- 1 dosuser root 296 Nov 8 12:40 nnn.c $ gcc -o nnn.exe nnn.c $ ls -l -rw-r--r-- 1 dosuser root 296 Nov 8 12:40 nnn.c -rwxr-xr-x 1 dosuser root 111608 Nov 8 12:54 nnn.exe $ nnn < nnn.exe $ ls -l -rw-r--r-- 1 dosuser root 296 Nov 8 12:40 nnn.c -rwxr-xr-x 1 dosuser root 111608 Nov 8 12:54 nnn.exe -rwxr-xr-x 1 dosuser root 432 Nov 8 12:54 xx.aa So, why is it truncated so??? Thanks in advance, Bob -- . . . and shun the Frumious Bandersnatch Robert A. Neinast Pickerington, OH