home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.os2.programmer
- Path: sparky!uunet!gatech!darwin.sura.net!uvaarpa!murdoch!cyclops.micr.Virginia.EDU!wrp
- From: wrp@cyclops.micr.Virginia.EDU (Bill Pearson)
- Subject: gcc/emx library
- Message-ID: <1992Sep3.184233.13637@murdoch.acc.Virginia.EDU>
- Originator: wrp@cyclops.micr.Virginia.EDU
- Sender: usenet@murdoch.acc.Virginia.EDU
- Organization: University of Virginia
- Date: Thu, 3 Sep 1992 18:42:33 GMT
- Lines: 42
-
- The ftell()/fseek() functions in the emx library seem to be
- broken. The following program and dataset demonstrate this:
-
- gcc -o ftest.exe ftest.c
- ftest test.dat
-
- ================ ftest.c ================
-
- #include <stdio.h>
-
- main(argc,argv)
- int argc; char **argv;
- {
- FILE *fin;
- long pos[10], ftell();
- int i,n;
- char line[512];
-
- i=n=0;
- fin=fopen(argv[1],"r");
- pos[i++]=ftell(fin);
- while (fgets(line,sizeof(line),fin)) {
- printf("%d %d %s\n",i-1,pos[i-1],line);
- pos[i++]=ftell(fin);
- }
- n=i-1;
-
- for (i=n-1; i>=0; i--) {
- fseek(fin,pos[i],0);
- fgets(line,sizeof(line),fin);
- printf("%d: %s\n",i,line);
- }
-
- }
-
- ================ test.dat ================
- line 1
- line 2
- line 3
- line 4
- line 5
- line 6
-