newbie fscanf %[ conversions, multipliers



Hi,

I am using fscanf() to read words. But I want to match alphanumeric
characters only. However the program, when using the conversion
specifier %255[a-z,A-Z] prints only spaces and other non-standard
ascii characters. I have listed a small example below. Can someone
please tell me what I am doing wrong or forgetting, with regards to
the conversion specifier ? Thankx. !

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAXWORDLEN 256

int main(void) {
char word[MAXWORDLEN];
char *bigr[2];
int i = 0;

bigr[0] = calloc(MAXWORDLEN, sizeof(char));
bigr[1] = calloc(MAXWORDLEN, sizeof(char));

while(fscanf(stdin, "%255[a-z,A-Z]", word) != EOF) {
strcpy(bigr[i++], word);
if(i == 2) {
printf("%s %s\n", bigr[0], bigr[1]);
strcpy(bigr[0], bigr[1]);
i = 1;
}
}

return 0;
}
.



Relevant Pages

  • Re: Problem with linker
    ... but to have actually written a default constructor. ... such as overloading on int and pointer types. ... conversion of 0 to CString requires a user-defined conversion, ... acceleration operator *(distance d, time_squared t2); ...
    (microsoft.public.vc.mfc)
  • Re: Interesting list Validity (True/False)
    ... TypeError: int argument required ... If the gmpy writers are not allowing the conversion, ... it raises an OverflowError and the "%d" formatting ...
    (comp.lang.python)
  • Re: if(a);
    ... The type of the octal signed int literal 0 will be compared to the ... 'a' has type unsigned int, in which case 0 is converted to ... is still 0 after undergoing conversion, ...
    (comp.lang.c)
  • Re: what if (f)printf returns EINTR ?
    ... vsnprintf - formatted output conversion ... int fprintf; ... write to the character string str. ...
    (comp.unix.programmer)
  • Re: printf("%s ", __FILE__); /* why SIGSEGV? */
    ... printf that matched a %d conversion in a printf call were implicitly ... unsigned int just because it appears in a function call in a position ... range of value and otherwise to unsigned int. ... these apply the integer promotions and also do float->double. ...
    (comp.lang.c)