home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / os2 / programm / 4765 < prev    next >
Encoding:
Text File  |  1992-09-07  |  1.8 KB  |  51 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!Sirius.dfn.de!solaris.rz.tu-clausthal.de!news!ipc1.rrzn.uni-hannover.de!gruen
  3. From: gruen@ipc1.rrzn.uni-hannover.de (Lutz Grueneberg)
  4. Subject: Re: gcc/emx library
  5. Message-ID: <1992Sep5.173414.20813@newsserver.rrzn.uni-hannover.de>
  6. Sender: news@newsserver.rrzn.uni-hannover.de (News Service)
  7. Reply-To: gruen@ipc1.rrzn.uni-hannover.de
  8. Organization: University of Hannover
  9. References:  <1992Sep3.184233.13637@murdoch.acc.Virginia.EDU>
  10. Date: Sat, 5 Sep 1992 17:34:14 GMT
  11. Lines: 38
  12.  
  13. In article <1992Sep3.184233.13637@murdoch.acc.Virginia.EDU>, wrp@cyclops.micr.Virginia.EDU (Bill Pearson) writes:
  14. |>     The ftell()/fseek() functions in the emx library seem to be
  15. |> broken.  The following program and dataset demonstrate this:
  16. lines deleted
  17. |>     fin=fopen(argv[1],"r");
  18. |>     pos[i++]=ftell(fin);
  19. |>     while (fgets(line,sizeof(line),fin)) {
  20. |>         printf("%d %d %s\n",i-1,pos[i-1],line);
  21. |>         pos[i++]=ftell(fin);
  22. |>     }
  23. |>     n=i-1;
  24. |> 
  25. |>     for (i=n-1; i>=0; i--) {
  26. |>         fseek(fin,pos[i],0);
  27. |>         fgets(line,sizeof(line),fin);
  28. |>         printf("%d: %s\n",i,line);
  29. |>     }
  30. You are right. There is a somewhat funny behavior of the emx library.
  31. If you want to use random file access you should use the binary
  32. mode to access files ("rb"). You opened the file in text-mode ("r"). 
  33. There is a bug in the library documentation. Standard mode for files
  34. should be binary but in reality it is text mode. In binary mode
  35. all goes right, I had problems with this too and asked Kai Uwe Rommel.
  36. He confirmed the bug. Eberhard Mattes knows it too.
  37.  
  38. Lutz
  39. -- 
  40. // Lutz Gr"uneberg
  41. // Lehrgebiet Rechnernetze und Verteilte Systeme
  42. // Universit"at Hannover
  43. // Schlosswender Str. 5
  44. // D-3000 Hannover 1, Germany
  45. //
  46. // Email: Grueneberg@rrzn.uni-hannover.dbp.de
  47. //
  48. //                ... have a  n.i.c.e. day
  49.  
  50.  
  51.