This code:
Code:
#include <string.h>
#include <stdio.h>
#include <ctype.h>
int isnumber(char* word)
{
int i = 0;
while(word[i] != '\0')
{
if(isdigit(word[i]) == 1)
i++;
else {
printf("word[%d] gives %d.\n", i, isdigit(word[i]));
return 0;
}
}
printf("Return 1\n");
return 1;
}
int main(void) {
char foo[] = "15";
int bar = isnumber(foo);
printf("bar is %d.\n", bar);
return 0;
}
prints
Code:
word[0] gives 4.
bar is 0.
on my (Win32) system. I'm guessing you should reexamine your idea of "true" in C.