[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
format specifier %[blah] for fscanf
From: |
Matt R |
Subject: |
format specifier %[blah] for fscanf |
Date: |
Thu, 18 Oct 2001 20:53:59 +1000 |
HI there libc Gurus,
I am hoping that this is an appropriate place to ask this question.
please reply directly to this email, as I am not a member of the list.
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.
Am I just an idiot, and am using the format modifier incorrectly, or is there
something missing from the library here?
Any help appreciated,
thanks,
Matt
- format specifier %[blah] for fscanf,
Matt R <=