I need a way to check if a string contains only alphabetic characters. Since I need a function several times in my program, I thought it was a good idea to include it in a function.
Here is my implementation:
int sisalpha(const char *s) {
int result = 1;
while (s++ != '\0') {
result = isalpha(*s);
if (result == 0) {
return result;
}
}
return result;
}
What can I improve here? Would it also be useful to pass some size to avoid buffer overflows and allow substring checking?
source
share