Article View: comp.os.msdos.programmer
Article #2736Quick Stream Field hack
From: LAUGHLIN, CHET
Date: Sat, 20 Oct 1990 04:31
Date: Sat, 20 Oct 1990 04:31
26 lines
1568 bytes
1568 bytes
Maybe someof you already know this, but there is a quick way to read
in string fields from a stream. Simple use fscanf with the [^XYZ]
format (look it up..d:) where X, Y and Z are end-of-field characters.
I hope this saves someone a sleepless night. I can now do in two lines
what use to take me 10 or so....and it only took me 5 years to stumble
apon it while reading the run-time library manuals (what a dedicated
guy! d:)
For example, one can use the following to 'type' a DOS file...
while(!feof(fh))
{
fscanf(fh,"[^\n] ",tempstr);
printf("%s\n",tempstr);
}
WARNING!!! It is important to have the white space after the end bracket.
If your end-of-field is not a white space I'm not sure what you would
have to replace the space with......
+---------------------------------------------------------------+
| Chet Laughlin CTL8588@RIGEL.TAMU.EDU |
| "I have no opinions as I (128.194.4.4) |
| do not exist, my lawyers |
| told me so." |
+---------------------------------------------------------------+
Technical Details
Message-ID:
<9355@helios.TAMU.EDU>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!helios!rigel.tamu.eduShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!helios!rigel.tamu.edu From: ctl8588@rigel.tamu.edu (LAUGHLIN, CHET) Newsgroups: comp.os.msdos.programmer Subject: Quick Stream Field hack Message-ID: <9355@helios.TAMU.EDU> Date: 20 Oct 90 04:31:51 GMT Sender: usenet@helios.TAMU.EDU Reply-To: ctl8588@rigel.tamu.edu Organization: TAMU Lines: 26