I ask for your help. I need to compare an array of tokens with a char using the if statement. But in the array I also have a string, the code is this:
char bho(char** Token){
char* token = (char*)Token;
enum TokenType type;
int len_token = strlen(token);
for (int i = 0; i < len_token; i++){
if(Token[i] == NULL){
continue;
}else if (Token[i] == '='){
type = Equals;
printf("{value: %s, type: %d}\n", Token[i], type);
} else {
printf("{value: %s}\n", Token[i]);
}
}
}
int main(void){
char input[] = "Ciao = l";
char** array;
array = tokenizer(input);
bho(array);
}
tokenizer() is a function that splits the input string and put the parts into an array. The enum TokenType is an enum that I need to categorize the type of all the content of the array.
The problem is that my program has the output of:
output:
{value: Ciao}
{value: =}
{value: l}
but the output it has to give me is:
output:
{value: Ciao}
{value: =, type: 4}
{value: l}
I do:
for (int i = 0; i < len_token; i++){
if(Token[i] == NULL){
continue;
} else if(Token[i] == '='){
type = Equals;
printf("{value: %s, type: %d}\n", Token[i], type);
} else {
printf("{value: %s}\n", Token[i]);
}
}
but give me the error: comparison between pointer and integer. I tried various methods but can't make it work.
Sorry if I wrote with incorrect grammar but i did fatigue with the write in English.
Tokenachar**instead of e.g. achar*(i.e. why the double pointer) ?else if (Token[i][0] == '=')