You have the right idea. A letter is just a number.
Code:
#define MAX_LENGTH 256
#include <stdio.h>
int main() {
char sentance[MAX_LENGTH]; // Holds the sentance
int x = 0; // Holds the current posistion for the search
int y = 0; // Holds total number of a's found
printf("Enter a sentance\n"); // Gets input
fgets(sentance, MAX_LENGTH, stdin);
while(sentance[x] != '\0') { // Loop threw sentance
if(sentance[x] == 'a') // Chech to see if the current character is a a
++y; // It is, add one to y
++x; // Update posistion
}
printf("\nThere are %i letter a's in your sentance\n", y); // Print answer
return 0;
}
// Wonder why I did c++ comments in c code when I dont do c++