Please help me with my code below. I cannot seem to get the argv[1] (the key) to loop around plaintext. For example, if I my key is "bacon", and the plaintext is "Meet me at the park", I only get "Negh z". I tried to use modulo to loop, e.g., k % strlen(argv[1]), but that does not seem to work.
Here is part of my code: (I excluded the parts for lowercase k, uppercase n, and for spaces)
for (int i = 0, n =0; n < strlen(plaintext); n++)
{
char k = argv[1][i];
//for uppercase k
if (isupper(k))
{
if(isalpha(plaintext[n])
{
//for lowercase n
if(islower(plaintext[n]))
{
printf("%c", ((((plaintext[n] - 'a') + k) % 26) + 'a'));
}
i++;
}
}
}