the code does all ok at check50, but

encrypts "BaRFoo" as "CaQGon" using "BaZ" as keyword \ expected output, but not "BzREon\n"

Edit: code deleted due to academic honesty

2 Answers 2


Without seeing the rest of your code, I can only take a guess as to what your issue may be.

I believe that since you are not updating the user's input in real-time nor storing the value of keynum, your program takes the single value stored in keynum and cyphers the user's input (keyword) with it. If you run through keynum and the user's input, adding the ith place of keynum to the ith place of the keyword, only one letter will be changed.

Two other things I noticed; first, check out the values your are subtracting from keyword[k]. If I cypher something with the letter a, I am looking to keep the original letter the same, not alter it. Second, you are going to want something in your code that skips over spaces and other non-alpha characters.

  • thank you for you answer, i just edited with all the code, i've also changed the substracting values. i think the problem is about how the code to get the key is made. it works for 1 letter keyword but not with more.
    – GermánSH
    Oct 20, 2015 at 19:56
  • I think you are overcomplicating some of it. Have you tried using GDB at all? I think you may find it helpful for this problem.
    – peachykeen
    Oct 20, 2015 at 21:54
  • after trying i removed the for loop for the keyword and set a variable at the previous one, also changed how to do the cypher, now i pass the check50 for keywords a baz and BAZ, but not BaZ.
    – GermánSH
    Oct 21, 2015 at 21:02

It was somithing wrong with the counter, at the end instead of making j = strlen(keyword) i made a formula using % that is more usefull and allow me to meka a more compact code.

i edit the code due to academic honesty

You must log in to answer this question.

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