I am having trouble with my code being new to C. I am simply trying to get this program to print the index where string[j] = "a". If I take out the if statement, the program will flawlessly print out all the index positions, but it doesn't work with the if statement. It is very simple for me to do this in other languages. How do you achieve this in C?
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
char string[100] = "Smart Guy";
for(int j = 0; j < strlen(string); j++) {
if (string[j] == "a") {
printf("%d %c\n", j, string[j]);
}
}
return 0;
}