I finished my vigenere and it works good with all the parameters but when I go through check50 with BaZ keyword, check50 give this answer

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

I hope you guys can give some word of advice, Thanks a lot.


  • 1
    Looks like there's something wrong with your ciphering formula.
    – kzidane
    Aug 25, 2014 at 9:31
  • 2
    The \u0000 means that there is a unicode character being inserted after the a and o. Check that the function is appending characters, and not strings. Aug 25, 2014 at 18:31
  • I have the same problem with \u0000 .
    – user2573
    Oct 3, 2014 at 1:25

1 Answer 1


First you have to covert whole key to upper case then use it....

like here "BaZ" should convert in "BAZ"

  • Yes, thank you for this tip. This solved the problem I have been stuck on for some time. Why does it have to be converted though?
    – MrNiceGuy
    Mar 25, 2015 at 19:16
  • how do you do that?
    – peter
    Jun 23, 2015 at 18:22
  • I don't undserstand why the keyword has to be converted to upper case ..can some one please explain ... ? Jun 27, 2015 at 6:07
  • Yes can someone please elaborate on this Sep 6, 2015 at 21:10
  • 2
    @GettingTheHang-of-it, you don't strictly have to convert the key to upper case, you just have to make sure that no matter whether the user inputs: baz, Baz, bAz, baZ, bAZ, BaZ, BAz, or BAZ that key is { 1, 0, 25}. There are a few ways to accomplish this; one of them is to convert the whole key to upper case. You could also put it all in lower case, or, just handle the case char by char.
    – Sam Gerber
    Sep 21, 2015 at 5:43

You must log in to answer this question.

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