So basically I got string array, lets say a[i][b];
so the code looks something like this –
for(int i = 0; i < 3; i++) {
for(int n = 0; b < 3; b++) {
if(a[i][b] == "s") {
cout << a[i][b] << endl;
}
}
}
the array exists, and I can check it if I just show on console the a[i][b] without if statement, but with if statement it gives me this error –
error: ISO C++ forbids comparison between pointer and integer
Is there any way to fix that?
“s” is a string literal, i.e. a character array, so decays to a pointer. To just compare to a character, use single quotes: