Im trying to figure out Vigenere from pset2. My program doesn't print out the letters of my plaintext more than once, it prints the fist letter no problem but doesn't print the second, third, ect. It did print at one point but it had errors and in the midst of trying to fix those errors i produced more =[.
Here is my code i really hope someone can help.
for (int i = 0, pl = strlen(p); i < pl; i++)
{
j = index % kl;
char current = p[i];
if (isupper(current))
{
if(isupper(k[j]))
{
int highresult = ((current - 'A') + ( k[j] - 'A')) % 26 + 'A';
printf("%c", highresult);
index++;
}
}
else if(isupper(current))
{
if (islower(k[j]))
{
int lowresult = (current - 'a') + ( k[j] - 'a') % 26 + 'a';
printf("%c", lowresult);
index++;
}
}
else if (islower(current))
{
if(isupper(k[j]))
{
int highresult = ((current - 'A') + (k[j] - 'A')) % 26 +'A';
printf("%c", highresult);
index++;
}
}
else if (islower(current))
{
if(islower(k[j]))
{
int lowresult = (current - 'a') + (k[j] -'a') % 26 + 'a';
printf("%c", lowresult);
index++;
}
}
else
{
printf("%c", p[i]);
}
}
the Code is only my for loop as you can see. if there is anything else you need to help me just ask please!
Thanks!