This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
format specifier %[blah] for fscanf
- To: gcc-help at gcc dot gnu dot org
- Subject: format specifier %[blah] for fscanf
- From: Matt R <nimrod99 at dingoblue dot net>
- Date: Thu, 18 Oct 2001 21:39:12 +1000
- Reply-To: nimrod99 at dingoblue dot net
HI there GCC 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)...
(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. The info files describe the modifier as
I have used it above...but it does not appear to work.
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