#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int count_letters(string text);
int main(void)
{
string input = get_string("Text: ");
int letters = count_letters(input);
printf("%i\n",letters);
}
int count_letters(string text)
{
int i = 0;
char l = text[i];
int len = strlen(text);
do{
i++;
}while(isspace(text[i]) == 0 || l != '\0');
return i;
}
I wrote a code which counts number of letters in a sentence(excluding white space).but when I run it, its showing Segmentation fault (core dumped)
. can anyone help me where i went wrong?