3
votes
How to Encrypt Plaintext Properly When it Contains Non-Alphabetical Chars?
As others have said, you can reduce your loops by combining what they do into one loop. You don't need to store the user input, so you can modify it without worry.
Other than that, I would just add ...
1
vote
Accepted
My cipher algo is wiping out my keyword!
Buff! This is a hidden problem related to the preprocessing of the key. First of all, saying that trying to change a variable of type char * is not a good idea, however we can do this in vigenere ...
1
vote
PSET2: Can't figure out what's wrong with my crack.c code?
The problem is that you have essentially created an infinite loop.
Initially when your while code starts, your first for loop runs, then your second, then third and then fourth but they never check ...
1
vote
Accepted
CS50 pset2 Caesar's cipher - Compile but doesn't work?!? GetString() above and beyond
In testing your code, it appears to ask for the string correctly. However, if there is a non-alpha in the string, it will go into an infinite loop in the while loop because the only time you ...
1
vote
Accepted
Why Doesn't Vigenere Give the Correct Output?
Your check
if(j >= length_k )
{
j= j%length_k;
}
Just move this check to right after j++. like this
j++;
if(j >= length_k )
{
j= j%length_k;
}
That should solve your problem.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
encryption × 10pset2 × 8
vigenere × 4
caesar × 4
cs50x × 2
c × 2
crack × 1
problem × 1
crypt × 1
cipher-pset2 × 1
crack.c × 1
key × 1
substrings × 1
cs50-pset2 × 1