Addmitedly and obviously I am new to this coding thing. I'm enjoying working it out but I feel stuck on this problem. Any guidance would be appreciated!
I am attempting to count all of the letters of a particular text from the user, but my counter (i) comes out as 1 when I run the program regardless of input. Below is my code.
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
string a = get_string("Text: \n"); // Get input
for (int i = 0, n = strlen(a); i < 1; i++) //Set counter for number of letters
{
if isalpha(a[i]). // Count only if character is a letter
{i++;}
printf("%i\n", i); // print counter
}
}
Again, any guidance (in as simple of terms as possible!) is appreciated as I've been trying to figure this out for two days.