I'm currently on vigenere, and trying to make sure that the keyword does not contain any non-alpha characters. If there's a non-alpha character, the program should return 1 to main. Here is my code:
for (int i = 0, j = strlen(argv[1]); i < j; i++)
{
if (isalpha(argv[1][i]) != 1)
{
printf("Error - please make sure you type in your cipher as just one string.\n");
return 1;
}
}
Its not working - the program doesn't exit if i give a keyword with non-alpha characters, and my guess is because it's returning 1 within the for loop, so the loop keeps running.
How can I break out of the loop to return 1 if the condition is true?