I'm trying to write some code that will take input, loop through the characters in the input, and print "hi" for every "a" that shows up in the input.
I'm getting errors trying to compare the looped characters in the string to "a". I'ts a problem with comparing pointers and integers.
How can I avert this problem (by either changing the types of the variables present or something?)
#include <stdio.h>
#include <string.h>
#include <cs50.h>
#include <ctype.h>
string name;
char x;
char *y;
int main(void){
printf("Name:");
name = GetString();
printf("\n");
if (name != NULL){
for (int i = 0, n = strlen(name); i < n; i++)
{
x = name[i];
y = "a";
if (x == y){
printf("hi");
}
}
}
}