1

I'm stuck on an issue with my code. After completing my code and making sure it works as should, I run check50 and this is what I get;

jharvard@appliance (~/Dropbox/pset2): check50 2014/x/pset2/vigenere  vigenere.c
:) vigenere.c exists
:) vigenere.c compiles
:( encrypts "a" as "a" using "a" as keyword
        \ expected output, but not "a"
:( encrypts "world, say hello!" as "xoqmd, rby gflkp!" using "baz" as keyword
        \ expected output, but not "xoqmd, rby gflkp!"
:( encrypts "BaRFoo" as "CaQGon" using "BaZ" as keyword
        \ expected output, but not "CaQGon"
:( encrypts "BARFOO" as "CAQGON" using "BAZ" as keyword
        \ expected output, but not "CAQGON"
:) handles lack of argv[1]
:) handles argc > 2
:) rejects "Hax0r2" as keyword

https://sandbox.cs50.net/checks/50928904a6124b57a206e0a4c9291325

Can someone tell me why check50 is not receiving the correct output? I've been stuck on this for a while and could use some help. As you can see, the program does what it should. Anything would be helpful, thanks.

3
  • I have another question... If your keyword is BaZ shouldnt the encrypted message end with a capital letter like CaQGon BaZBaZ n and Z do not match... Have anyone noticed this too?
    – JAraujo
    Commented Aug 7, 2014 at 14:48
  • @JAraujo No, the keyword is case-insensitive. See the specification where it says, "As for the characters in k, you must treat A and a as 0, B and b as 1, … , and Z and z as 25." So there's no difference between the keywords BaZ and BAZ.
    – Air
    Commented Aug 7, 2014 at 15:10
  • Yes I have seen it now thank you I have already managed to submit caesar and vigenere without erros. Did you understand what you did wrong already? You probably forgot the \n (I made this mistake too) specifically after the last char of the string as John has already advised ;)
    – JAraujo
    Commented Aug 8, 2014 at 1:04

2 Answers 2

4

This is a very common error. You've forgotten to include a control character in your output, and it's not showing up in the message from check50 in Terminal because it's a non-printing character.

It's easier to see the problem when you expand one of the failed check tasks in your sandbox link. For instance, the third check (first one to fail) has this line in the expanded view:

4 Expecting the following on standard out —  a\n    ... but received the following on standard out instead —  a

There you can see that what you're missing is the \n newline character. Unfortunately, the requirement to include this character isn't made particularly clear in the pset specifications - again because the newline is a non-printing character and not visible in the "Ovaltine" example output!

2
  • Hi, This is helpful. But where do I add the \n if this is a non-printing character?
    – Jen Choi
    Commented Nov 20, 2014 at 20:26
  • @JenChoi Simply add \n to the string in your printf function. Although this character doesn't print to the screen, it does affect where the next character is printed. For example, try printf("This\nprints\non\nfive\nlines.\n"); (online demo).
    – Air
    Commented Nov 20, 2014 at 20:35
3

Looks like you just forgot to print a trailing "\n". Your program should output the encrypted message and a trailing newline character.

You must log in to answer this question.

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