OK, I have tried everything, but there still seems to be something wrong with my code for vigenere cipher. I mean I can't get it to loop through the keyword when the word is longer than it. I swear I have tried everything, but it just doesn't seem to work. Since I don't want to post my code here, would someone be willing to have a private message from me with my code in order for debugging? Thanks.
In order to loop through the keyword, you need to use the modulo operator.
For example, say your keyword is 5 characters long, while the text-to-be-enciphered is 10 characters long. At the beginning of your code you will have some for loop like this:
for (int i = 0, n = strlen(plain), k = 0; i < n; i++, k++)
Here, k is used to access consecutive characters of your
argv key. However, in order to loop through your keyword, you cannot use k, but need to use the modulo, like this:
int j = k % strlen(argv); // ensure looping of key
The modulo divides your loop number by your key length, and as a result gives you the remainder of the result. This remainder can never be longer than the number you are dividing by, and therefore you will only get numbers from 0 to 4 (in the case of your keyword being 5 characters long).
Now, you can use
argv[j] to access the consecutive characters of your key in a loop.