I can't fix this logical problem. I have a check_alpha function which should return if all characters are alphabetic.
bool check_alpha(char key[])
{
for (int i = 0, n = strlen(key); i < n; i++)
{
if (isalpha(key[i]))
{
printf("everything ok\n");
}
else {
printf("not alpha.\n");
}
}
return false;
}
And before that in my main function I have this condition
else if (argc == 2 && !(check_alpha(argv[1])))
{
printf("Key must only contain alphabetic characters.\n");
return 1;
}
With current code and with argv of 26 alphabetic characters, I still get "Key must only contain alphabetic characters." If I change my logic, it still doesn't work properly, doesn't matter what I try. On the other hand, printf statements in my check_alpha function show me that it is working properly. Any help, what am I doing wrong? Ideally, if all 26 characters are letters, it should procede to check next condition...