home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20183 < prev    next >
Encoding:
Text File  |  1993-01-25  |  1.5 KB  |  44 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!utcsri!geac!torsqnt!tmsoftware.ca!lsimages!whome!camaro!las
  3. From: las@camaro.uucp (Laszlo Herczeg)
  4. Subject: how do I search for <lf>, (ASCII(10))?
  5. Organization: camaro
  6. Date: Mon, 25 Jan 1993 06:16:10 GMT
  7. Message-ID: <1993Jan25.061610.15931@camaro.uucp>
  8. Lines: 34
  9.  
  10. Hello big programmers:
  11. How do I search for the line-feed (instead of the EOF character) when
  12. reading a string from a file.
  13.  
  14. Here is what I have right now:
  15. if(fgets(path,sizeof(path),fp) !=EOF){
  16.  
  17. Now, my problem is that fgets also returns ASC(10) and ASC(13), and I
  18. don't know how to get rid of them.
  19.  
  20. The program I am writing is supposed to read the batch file pat.bat
  21. which contains the current path. I'd like to manipulate the contents
  22. of this file, and then write back to it, but when I do, C preserves
  23. the line formatting characters, so the revised pat.bat does not
  24. execute properly.
  25.  
  26. I have gotten around the problem temporarily by manually removing the
  27. control chracters from the file, but there must be a better way.
  28.  
  29. So I have two questions:
  30. 1. Is it possible to search for asc(10) specifically, and stop there?
  31. 2. If not, is it possible to strip the string stored in "path" of the
  32. EOF characters?
  33.  
  34. Many thanks in advance,
  35. Laszlo 
  36.  
  37. -- 
  38. ***************************************************************************
  39. Laszlo Herczeg         e-mail:las@camaro.UUCP (running on LINUX 0.99)
  40.                        e-mail:las@eastern.com
  41.                        e-mail:las@r-node.gts.org
  42.          "Many a good hanging prevents a bad marriage,..."
  43.  
  44.