I've finally fixed the other problems from check50, including the Hax0r2 check but my code appears to be terminating before it starts enciphering. For each of the enciphering checks on check50 I'm getting the error:

\ expected output, but not "Please enter your single word key",

(which is, of course, the return 1: prompt.) Here is a short segment of the code. Obviously only part of the cipher code is here to avoid spoilers. I hope someone can advise me.

int main(int argc, char* argv[]) 
    if ((argc<2) || (argc>2) || (!isalpha(strlen(argv[1]))))
        printf("Please enter your single word key");
        return 1; 
        char* word = GetString();

        char* key = (argv[1]);    

        int keylen = strlen(key);
        int wordlen = strlen(word); 

        for(int wordpos = 0, keypos = 0; wordpos<wordlen; wordpos++)

            int cipher = (wordpos + keypos -65) % 26 + 65; 
            printf("%c", cipher);

1 Answer 1


You are checking whether strlen(argv[1]) is alphabetic, which of course it never will be. That's why the code is always exiting on the first conditional. Did you actually run it and check the output?

  • It won't compile if the 1 is removed or replaced with anything else. If I leave the [] empty or remove them it throws an error when I try to compile. When I run check50 it checks if argv is alpha. That particular check works when the code is as it is there, otherwise that throws an error on check50. If I replaced the 1 with an i it threw an undeclared identifier error. Not sure how else to approach that.
    – Android1
    Commented Mar 18, 2017 at 9:02
  • You are checking whether the length of argv[1] (a number) is alphabetic rather than whether argv[1] (a string) is alphabetic. In order to do this in C, you have to loop over each char in argv[1] and use the function isalpha() on each one. Commented Mar 18, 2017 at 10:40
  • That's what I had originally. It compiles but it doesn't pass check50 checks because it doesn't check the whole length of the keyword at argv. When I run the checks I then get the Hax0r2 error which says it is supposed to exit because there are numbers in the key. I just also tried adding another 'if' statement underneath to iterate through argv after declaring it a key to check if each character isalpha before returning 1 but it rejected that too. Very frustrating. :-{ That one also compiled but failed check50.
    – Android1
    Commented Mar 18, 2017 at 10:41

You must log in to answer this question.

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