www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/13/13:33:20

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Reading in a configuration file
Date: 13 Jul 2000 16:12:39 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 21
Message-ID: <8kkppn$iiq$1@nets3.rz.RWTH-Aachen.DE>
References: <8kkotd$lrp$1 AT sunbeam DOT coventry DOT ac DOT uk>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 963504759 19034 137.226.32.75 (13 Jul 2000 16:12:39 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 13 Jul 2000 16:12:39 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Steve Johnston <s DOT johnston AT coventry DOT ac DOT uk> wrote:
[...]

> At the moment I use fscanf() for the obtaining the values I want -
> is there any way I can get it to jump to the next line in the file
> once its read in one floating point value?

You could use

	fscanf(file, "%d%*[^\n]%*[\n]", value);

But the usual approach to scanning line-oriented, 'free' format input
is not to use fscanf(), but instead fgets() to read in the text, a
line at a time, and then use sscanf() on the resulting string. fgets()
has the advantage that it does make a difference between line ends and
white space, unlike all but the most experienced users' scanf()
strings do.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019