format specifier %[blah] for fscanf

Matt R nimrod99@dingoblue.net
Thu Oct 18 09:20:00 GMT 2001


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




More information about the Gcc-help mailing list