I'm trying to implement a substitution cipher but my output is printing on the following lines rather than on the same line. For example, if my key is VCHPRZGJNTLSKFBDQWAXEUYMOI
, then HELLO
should output JRSSB
, which my code does but it looks like this (I've attached a screenshot of the output as well):
JR \n
S \n
SB
printf("ciphertext: ");
for (int i=0; i<strlen(plain); i++)
{
if (arr[i]>90 || arr[i]<65)
{
printf("%c", arr[i]);
}
for (int j=0; j<strlen(key); j++)
{
if ((arr[i]==j) && (lower == true))
{
printf("%c", key[j]+32);
}
else if (arr[i]==j)
{
printf("%c", key[j]);
}
}
}