newbie fscanf %[ conversions, multipliers
- From: Steven <Steven@xxxxxxxxx>
- Date: Tue, 27 Dec 2005 18:12:01 +0100
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;
}
.
- Follow-Ups:
- Re: newbie fscanf %[ conversions, multipliers
- From: Christopher Benson-Manica
- Re: newbie fscanf %[ conversions, multipliers
- From: Chris Torek
- Re: newbie fscanf %[ conversions, multipliers
- Prev by Date: Re: cast unsigned long to long
- Next by Date: `volatile' on local variable used outside of function
- Previous by thread: cast unsigned long to long
- Next by thread: Re: newbie fscanf %[ conversions, multipliers
- Index(es):
Relevant Pages
|
|