0

Check50 is telling me that none of the expected ciphers are working, however running each of them appears to give the exact same output it expects. I cannot see where the failure is coming from. Check50 output:

:) caesar.c exists.
:) caesar.c compiles.
:( encrypts "a" as "b" using 1 as key
    expected "ciphertext: b\n", not "b\n"
:( encrypts "barfoo" as "yxocll" using 23 as key
    expected "ciphertext: yxo...", not "yxocll\n"
:( encrypts "BARFOO" as "EDUIRR" using 3 as key
    expected "ciphertext: EDU...", not "EDUIRR\n"
:( encrypts "BaRFoo" as "FeVJss" using 4 as key
    expected "ciphertext: FeV...", not "FeVJss\n"
:( encrypts "barfoo" as "onesbb" using 65 as key
    expected "ciphertext: one...", not "onesbb\n"
:( encrypts "world, say hello!" as "iadxp, emk tqxxa!" using 12 as key
    expected "ciphertext: iad...", not "iadxp, emk tqxx..."
:) handles lack of argv[1]

Pastebin of my code: https://pastebin.com/UHV6rFrB

I know my code is a little messy, I am very new to this and trying to get better

1 Answer 1

3

The good news is: it looks like your ciphering algorithm is working. Yay. The bad news is you missed a important detail in the spec.

Notice the difference between what cs50 is expecting: "ciphertext: b\n" and what program is outputting: "b\n". It is the same difference on all the tests. CS50 is looking for ciphertext: before the cipher output.

From the instructions:

after validating the key, we prompt the user for a string (using "plaintext: " for the prompt) and then shift all of its characters by 1, printing out "ciphertext: " followed by the result and a newline.

2
  • OMG I can't believe I missed that. THANK YOU! I knew I missed something stupid like that. My reading comprehension can use some work.
    – De1337ny
    Feb 19, 2019 at 23:14
  • "When all else fails, read the directions" ??? ;-) In programming, close doesn't get it. Program specs have to be met precisely and exactly. A very important lesson, especially in team programming environments where all the pieces have to fit together later.
    – Cliff B
    Feb 20, 2019 at 4:47

You must log in to answer this question.

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