I've just started the vigenere task, and so far implemented only the starting point - a check, whether the keyword input is alphabetical. It works as intended, when the keyword starts with a non-alphabetical char, in all other cases it looks like the check is not working. What is the problem here?
#include <stdio.h>
#include <stdlib.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
int main (int argc, string argv[])
{
if (argc != 2)
{
printf("Don't joke with me, cowboy! I said enter the name of the programm AND one keyword ONLY. Try again!");
return 1;
}
string keyword = argv[1];
for (int i = 0, l = strlen(keyword); i < l; i++)
{
if (isalpha(keyword[i]))
{
return 0;
}
else
{
printf("Looks like you've entered an invalid keyword. Remeber, your keyword must contain letter only. Try again!");
return 1;
}
}
printf("Enter the text you want to cipher: \n");
}