isdigit and char string

Hello everybody.
Can someone please help me figure out what I'm doing wrong?
Here is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  char target[25] = {'\0'};
  printf("\nEnter a word to search for.\n");
  fgets(target,sizeof(target),stdin);
  strtok(target, "\n");
  while(strcmp(target,"-1") != 0){
	printf("Target is: %s  Top word is at pos: %d\n",target,wordCount);
	pos = FindAWord(lib,target,wordCount-1);
        if(pos == -1){
	        printf("The target word could not be found");
		printf("\nEnter a word to search for.\n");
		fgets(target,sizeof(target),stdin);
		strtok(target, "\n");
		continue;
	}
	if(isdigit(target[0])){
		int year = atoi(target);
                GetAnnualWLAvg(lib,year);
		printf("\nEnter a word to search for.\n");
		fgets(target,sizeof(target),stdin);
		strtok(target, "\n");
		continue;
	}
	if(isalpha(target[0])){
		GetAWordFrequency(lib,frq,pos);
		PrintGraph(frq,graph);
		printf("\nEnter a word to search for.\n");
		fgets(target,sizeof(target),stdin);
		strtok(target, "\n");
		continue;
	}
  }


The problem is with 'isdigit' routine.
No matter what I do, it refuses to see a digit and only a third 'if' statement
gets executed. I've tried: isdigit(*target), isdigit(target) and it didn't
work either. Ive also tried using integer string instead of char(int target[25])
but it didn't help.
Anyone...?

Thank you.
Last edited on
It would help to see the requirement/question, rather than having to reverse engineer it from broken code.
I apologize. I should've not posted all that code.
It's a program for Data Structures class.
Analising Google NGram word file.

This way it'll be easier to see.

1
2
3
4
5
6
7
 char target[25] = {'\0'};
 printf("Enter a word to search for.\n");
 fgets(target,sizeof(target),stdin);
 strtok(target, "\n");
 if(isdigit(target[0])){
      ... dosomething ...
 }


isdigit doesn't work.

Thank you.
Never mind. static_cast did it.
Thanks goes to John Harrison at
http://bytes.com/topic/c/answers/135032-isdigit-characters-greater-than-127-a
Topic archived. No new replies allowed.