On Thursday 14 March 2013 15:56, in comp.lang.c,
wrote:
> Joe Pfeiffer wrote:
>> Almost...
>>
>> %lf looks for a double, not a float. You need to either declare
>> double f1, f2, f3;
>
> Sorry brain fart typing in the small example, the original, much larger,
> code uses double.
>
>> or use %f
>>
>> sscanf() doesn't know about regular expressions. %127[^\n] is
>> meaningless.
>
> Hmm, not meaningless, but perhaps a gcc extension?
Nope. It's there in the C 1999 standard
ISO/IEC C 9899-1999 7.19.6.2 ("The fscanf function") paragraph 12 states:
12 The conversion specifiers and their meanings are:
...
[ Matches a nonempty sequence of characters from a set of expected
characters (the scanset)) If no l length modifier is present, the
corresponding argument shall be a pointer to the initial element of a
character array large enough to accept the sequence and a terminating
null character, which will be added automatically.
If an l length modifier is present, the input shall be a sequence of
multibyte characters that begins in the initial shift state. Each
multibyte character is converted to a wide character as if by a call to
the mbrtowc function, with the conversion state described by an
mbstate_t object initialized to zero before the first multibyte
character is converted. The corresponding argument shall be a pointer
to the initial element of an array of wchar_t large enough to accept
the sequence and the terminating null wide character, which will be
added automatically.
The conversion specifier includes all subsequent charactersin the
format string, up to and including the matching right bracket (]).The
characters between the brackets (the scanlist) compose the scanset,
unless the character after the left bracket is a circumflex(ˆ), in
which case the scanset contains all characters that do not appear in
the scanlist between the circumflex and the right bracket. If the
conversion specifier begins with [] or [ˆ], the right bracket character
is in the scanlist and the next following right bracket character is
the matching right bracket that ends the specification; otherwise the
first following right bracket character is the one that ends the
specification. If a - character is in the scanlist and is not the first,
nor the second where the first character is a ˆ, nor the last character,
the behavior is implementation-defined.
--
Lew Pitcher
"In Skills, We Trust"