home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / os2 / programm / 4717 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.1 KB  |  54 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!gatech!darwin.sura.net!uvaarpa!murdoch!cyclops.micr.Virginia.EDU!wrp
  3. From: wrp@cyclops.micr.Virginia.EDU (Bill Pearson)
  4. Subject: gcc/emx library
  5. Message-ID: <1992Sep3.184233.13637@murdoch.acc.Virginia.EDU>
  6. Originator: wrp@cyclops.micr.Virginia.EDU
  7. Sender: usenet@murdoch.acc.Virginia.EDU
  8. Organization: University of Virginia
  9. Date: Thu, 3 Sep 1992 18:42:33 GMT
  10. Lines: 42
  11.  
  12.     The ftell()/fseek() functions in the emx library seem to be
  13. broken.  The following program and dataset demonstrate this:
  14.  
  15. gcc -o ftest.exe ftest.c
  16. ftest test.dat
  17.  
  18. ================ ftest.c ================
  19.  
  20. #include <stdio.h>
  21.  
  22. main(argc,argv)
  23.     int argc; char **argv;
  24. {
  25.     FILE *fin;
  26.     long pos[10], ftell();
  27.     int i,n;
  28.     char line[512];
  29.     
  30.     i=n=0;
  31.     fin=fopen(argv[1],"r");
  32.     pos[i++]=ftell(fin);
  33.     while (fgets(line,sizeof(line),fin)) {
  34.         printf("%d %d %s\n",i-1,pos[i-1],line);
  35.         pos[i++]=ftell(fin);
  36.     }
  37.     n=i-1;
  38.  
  39.     for (i=n-1; i>=0; i--) {
  40.         fseek(fin,pos[i],0);
  41.         fgets(line,sizeof(line),fin);
  42.         printf("%d: %s\n",i,line);
  43.     }
  44.  
  45. }
  46.  
  47. ================ test.dat ================
  48. line 1
  49. line 2
  50. line 3
  51. line 4
  52. line 5
  53. line 6
  54.