Function to Check if string input from user is alphabetic only

Good Evening. I'm new to C. Can you please help me.
I'm creating an error checking function, user will input a string, this will check if the input is all alphabet or all letters only. If there is a digit or other special char, it will print Error then ask input from user again.

Here's my code. I don't know what's wrong

int isValid (const char str[], const int max) {
int i;
for (i=0; i<= max; i++) {
if (isdigit(str[i])) {
printf("Letters and spaces are only allowed\n");
return 1;

    \}

else \{

    return 0;

}
}
}

I'm from the Philippines. Thank you very much.

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Welcome!
This forum has very strict rules, either you are a student in a school /college / univ etc as so you are to complete ALL the template, if you want to see you post accepted here or you are a IT user ( or not...) willing to learn or study from books in which case you can post in the adequate forum which would be programming but we cannot accept unclear situations sorry
So repost again accordingly
All the best

1 Like