0

I get this error when I run check50

~/workspace/pset2/ $ check50 2016.vigenere vigenere.c
:) vigenere.c exists
:) vigenere.c compiles
:( encrypts "a" as "a" using "a" as keyword
   \ expected output, not a prompt for input
:( encrypts "world, say hello!" as "xoqmd, rby gflkp!" using "baz" as keyword
   \ expected output, not a prompt for input
:( encrypts "BaRFoo" as "CaQGon" using "BaZ" as keyword
   \ expected output, not a prompt for input
:( encrypts "BARFOO" as "CAQGON" using "BAZ" as keyword
   \ expected output, not a prompt for input
:) handles lack of argv[1]
:) handles argc > 2
:) rejects "Hax0r2" as keyword

On running the code with the same input parameters I do get the correct output. But check50 is not working correctly. For eg

~/workspace/pset2/ $ ./vigenere baz
world, say hello!
xoqmd, rby gflkp!
~/workspace/pset2/ $ 

I have looked at the solution posted for 2 similar "\ expected output, not a prompt for input" questions. I have my getstring() outside the for loop and I am not calling printf for any user prompt

Below is a part of my initial code

    string p;
    char cipher[100] = {0};
    if (argc != 2) {
        printf("You have to enter only one key! \n");
        return 1;
    }

    string k = argv[1];
    for (int i=0, n = strlen(k); i < n; i++){
        if (!isalpha(k[i])){
            printf("You you have entered digit(s)! \n");
            return 1;
        }
    }

    p = GetString();
    int len = strlen(k);

I am raking my brains to figure out what is going on.

Thank you!

2

Your output does not match the spec. The spec says

Implement a program that encrypts messages using Vigenère’s cipher, per the below.

  $ ./vigenere ABC  
   plaintext:  HELLO  
   ciphertext: HFNLP  

Your result should match exactly; you are missing some "things".

Specifically:

Otherwise, your program must proceed to prompt the user for a string of plaintext, p, (as by a prompt for plaintext:) which it must then encrypt according to Vigenère’s cipher with k, ultimately printing the result (prepended with ciphertext:) and exiting, with main returning 0.

| improve this answer | |
  • Thank you! That solved the problem :) – mgcoast Jan 9 '17 at 3:31
  • Thanks! I missed this little detail! – Loomernescent Jun 11 '17 at 3:24

You must log in to answer this question.

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