0

I get the following when running check50 on caesar.c:

:) caesar.c exists
:) caesar.c compiles
:) encrypts "a" as "b" using 1 as key
:( encrypts "barfoo" as "yxocll" using 23 as key
    \ expected output, but not "yx��c����\n"
:) encrypts "BARFOO" as "EDUIRR" using 3 as key
:) encrypts "BaRFoo" as "FeVJss" using 4 as key
:) encrypts "barfoo" as "onesbb" using 65 as key
:( encrypts "world, say hello!" as "iadxp, emk tqxxa!" using 12 as key
    \ expected output, but not "��adxp, em�� tqxxa!\n"
:) handles lack of argv[1]

Obviously it is the :( that have me confused. I believe I have the correct output format, with the first line being the program name and key, the next line the message to cipher and the last line the encrypted message with no additional text.

1
  • Check your formula for encryption, and also how do you read your key at the begging? Sep 23 '14 at 10:10
2
:( encrypts "barfoo" as "yxocll" using 23 as key
\ expected output, but not "yx��c����\n"

the error right above points out to a very common error that you too are making..

As you can see that some of the test cases pass the check50 hence you can be sure of the fact that it's not the printing format that has errors.

Moreover, focus on the error above from check50 to find the bugs in your program. You can see that the encrypted version is yx��c���� which has some unknown characters.

Let's see which characters on encryption lead to this gibberish output.

Hmmm, there are some odd appearances in the output. First of all, barfoo has 6 characters whereas the output has 12 characters. So, that's the problem, tour program somehow manages to add 6 more characters to the output, all of which are unreadable ie. those characters have ASCII values that are either too high or to low to be ASCII characters...

So, know you know the bug, hence, you can try debugging the program yourself, otherwise, consider your source code.

Best of luck debugging your program, and Happy Coding...

1

I found the bug.

For others facing a similar problem, be careful of the difference in how C handles characters versus integers, especially with integer values over 128.

0

I was having a similar error message:

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

Basically, Check50 is very picky with your code. Changing user prompt from all uppercase "PLAINTEXT:" to "plaintext:" resolves issue. Check your code to make sure it meets the outlined in the specification of the problem set!

You must log in to answer this question.

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