I’m working on a problem set for CS50 in C but I keep getting an error readability.c:11:1: error: expected identifier or '(' { and I’m not sure what’s wrong. Any help would be much appreciated.
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int count_letters(string text);
int main(void);
{
string paragraph = get_string("Input text: ");
count_letters(paragraph);
int L = 0;
int S = 0;
int index = 0.0588 * L - 0.296 * S - 15.8;
printf("%i", index);
}
int count_letters(string text)
{
int letters = 0;
for (int i = 0, length = strlen(text); i < length; i++)
if isalpha(text[i]) {
letters + 1
}
return letters;
}
>Solution :
You have a semicolon at
int main(void);
and you need one here:
for (int i = 0, length = strlen(text); i < length; i++){ //added {
if(!(isalpha(text[i]) == 0)){ // is alpha in brackets too and I usually prefer to check result with proper types
letters + 1; //addded ;
}
}