Reputation: 1
what I want to ask about is
something like this
char** words
int i =0;
while(words[i] != '\0'){
if(words[i] == "add"){
//do addition by previous value in words[i-1] and words[i-2] by atoi();
}
}
while I tried to solve this question, I used several different functions like strstr(), strcmp()
but I think I did some wrong about that
I need some smart person's help as soon as possible
Upvotes: 0
Views: 71
Reputation: 2373
This statement won't compare your strings, but addresses of variables. Pointer words[i]
with "add" which is string literal of type char[]
.
if(words[i] == "add")
use strcmp
if(strcmp(words[i],"add")==0)
Upvotes: 2