The following is my code, I'm not sure where I went wrong with my code, but when I run it, it seems to work for lower case letters but not uppercase. This isn't the full code, due to academic honesty, but I think the problem is in this section.
int main(int argc, string argv[]) { int KeyValue, change, result, KeyLength;
string text= GetString();
for(int i=0, j=0, length = strlen(text); i<length; i++, j++)
{
if(j>= strlen(key))
{
j=0;
}
KeyValue = key[j];
if(!isalpha(text[i]))
{
j=(j-1);
}
if((KeyValue>=65)&&(KeyValue<=90))
{
KeyValue = (KeyValue - 65);
}
if((KeyValue>=97)&&(KeyValue<=122))
{
KeyValue = (KeyValue - 97);
}
change = (text[i] + KeyValue);
if(isalpha(text[i]))
{
if(isupper(text[i]))
{
result=(((text[i] - 65) + (key[j%KeyLength]-65))%26)+65 ;
printf("%c", result);
}
else if(islower(text[i]))
{
text[i]=(((text[i] - 97) + (key[j%KeyLength]-97))%26)+97 ;
printf("%c", text[i]);
}
}
else
{
printf("%c", text[i]);
}
}
printf("\n");
return 0;
}