I'm trying to protect a program from invalid inputs and I've made a function that is not working in Linux but, apparently, works fine in Windows. I receive a String and the program is supposed to accept only Strings that have 3 " " and the last 3 values are digits. E.g "Mike 1 1 1".
The solution I came up with was
int verify(char string[]){
int n = 0;
char* aux = strtok(string, " ");
while((aux=strtok(NULL, " "))!=NULL){
if(isdigit(aux[0])==0)break;
n++;
}
return n;
}
If n is 3 I accept the input. I know that this solution won't be correct for an input like "Mike 1 1a 1" but for now that won't be important. I really wanted to know why this doesn't work in Linux and how can I test this in a way that will work.