Message-ID: <000701c168fc$bbe244e0$3bf092c3@cedric> From: =?iso-8859-1?Q?C=E9dric_Lucantis?= To: References: Subject: Re: Can't Even Read File Correctly Date: Fri, 9 Nov 2001 09:58:42 +0100 Organization: =?iso-8859-1?Q?POP'UP_Int=E9ractive?= MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Reply-To: djgpp AT delorie DOT com You are reading chararacters (text) from the standart input. Why didn't you open your file with "wt" instead of "wb" ? I remember I already had this kind of problem and I think (hope) it can be the solution ... ----- Original Message ----- From: Robert Neinast Newsgroups: comp.os.msdos.djgpp To: Sent: Thursday, November 08, 2001 6:56 PM Subject: Can't Even Read File Correctly > > 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 >