Hi please see the link for the code I am working with. I think the layout is correct but cannot seem to find the correct algorithm to solve this problem.
https://github.com/ionakathryn/cs50-pset2/blob/master/vinigere.c
Thanks
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.
Sign up to join this communityHi please see the link for the code I am working with. I think the layout is correct but cannot seem to find the correct algorithm to solve this problem.
https://github.com/ionakathryn/cs50-pset2/blob/master/vinigere.c
Thanks
I haven't run your code, but I have noticed a couple of points that could potentially cause a problem. Firstly in your printf statement on your first shift algorithm
printf("%d", ((p[j]-65)) + (toupper(k[count]-'A')) %26 + 65);
you have used %d
as a placeholder instead of %c
; %d
is used for numbers so you are likely to get a numeric value printed out here.
I believe there could be another possible issue with your k[count]
because you are incrementing count using count++
before you have used the original value. So you won't be accessing the first letter in your key (key[0]
) because you have already changed 0
to 1
before it is used.