0

I'm getting this Check50 error message for my Vigenere Cipher code:

rejects "Hax0r2" as keyword \ expected an exit code of 1, not a prompt for input

The task requires non-alpha keywords to be immediately rejected. How do I do this in this first block of code? The check50 checks expect the key to be iterated through then immediately rejected (as result 1:) and it's not enough just to put !isalpha for the whole argv key or this is rejected. Note: the print statement being removed or moved doesn't help. It appears it's required in the checks also.

This is the code:

int main(int argc, char* argv[]) 
{

if ((argc!=2) || (!isalpha(argv[1][0])))
{        
    printf("Please enter your single word key"); 
    return 1; 
}

Note: also the argc statements seem to be correct and are not causing the problem.

1 Answer 1

1

This !isalpha(argv[1][0]) is only testing the first character of argv[1]. Your statement "The check50 checks expect the key to be iterated through then immediately rejected" is quite true. The program, however, does not iterate through the key.

3
  • Hi, Dino. I thought that might be the case. Do you know of a way I can modify that to cause the whole of argv to be checked? (!isalpha(argv[1]) and (!isalpha(argv[]) don't work either. From the check50 result it has to happen in these couple of lines.
    – Android1
    Commented Mar 17, 2017 at 21:29
  • You'll have to iterate the old fashioned way...with a loop! isalpha works only on char (not on a string); you'll need to test each char in the string. Commented Mar 17, 2017 at 21:56
  • I found a better way. (!isalpha(strlen(argv[1])). It actually worked!
    – Android1
    Commented Mar 18, 2017 at 0:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .