[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: format specifier %[blah] for fscanf
From: |
Andreas Schwab |
Subject: |
Re: format specifier %[blah] for fscanf |
Date: |
19 Oct 2001 17:56:16 +0200 |
User-agent: |
Gnus/5.090003 (Oort Gnus v0.03) Emacs/21.0.107 |
Matt R <address@hidden> writes:
|> I have been fighting with using the above format modifier, without
|> any success (using glibc2-12 on redhat 7, with GCC 2.96-85)...
|> (crappy unsafe code as an example)
|>
|> #include <stdio.h>
|>
|> main() {
|> FILE *jock;
|> char jk[26];
|> jock = fopen("craper", "r");
|> fscanf(jock, "%25s", jk);
|> printf("%s\n", jk);
|> fscanf(jock, "%25[a-z]", jk);
|> printf("%s\n", jk);
|> fclose(jock);
|> }
|>
|> The first fscanf works fine, but the second does not return anything
sensible.
|> Is the %[blah] modifier supposed to work? The code compiles but does not
|> behave as expected.
You didn't tell us neither the contents of the file, nor the expected nor
the actual output ("not anything sensible" does not qualify), but be aware
that %[ does not skip initial whitespace.
Andreas.
--
Andreas Schwab "And now for something
address@hidden completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5