(i'm french, sorry for my bad english)
I don't know how to get an int from a char[], the patern of the char will be the same everytime : "prendre 2", "prendre 44", "prendre 710"...
I want to check if the pattern of the sentence is correct and get the integer.
I have try to do this, but as you see, the problem is i just can check if the integer is between 0-9 because I check only one char.
[...]
else if (est_prendre(commande)){
/* if the output is 1*/
int number = commande[8]- '0'
}
int est_prendre(char *commande){
int i;
char temp[9] = "";
char c = commande[8];
int num = c - '0';
for (i=0; i<8; i++){
temp[i] = commande[i];
}
if (strcmp ("prendre ", temp) == 0)
{
if ( /* num IS INTEGER? */)
{
return 1;
}
else
{
return 0;
}
} else {
return 0;
}
}
I expect if commande = "prendre 3", output of est_prendre is 1 because the pattern is correct And after than to put the integer into the variable number.
Thank You!