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