Hi everyone I'm having trouble with my code, it compiles just fine but when I go to do the plaintext to ciphertext it only shows 1-2 letters at a time instead of the whole word. Idk where could the issue be at, below is the part where I am losing confidence in when writing: update at the bottom
string p = get_string(" plaintext: ");
//enciphering the plaintext by the key
//enciphers 1 character at a time like upper case or lower case by the key, not spaces or puncuation marks.
printf(" ciphertext: ");
// looping through the text
for (int i = 0, n = strlen(p); i < n; i++)
{
// checking for uppercase or lowercase then converting.
if (islower(p[i]))
{
printf("%c",((p[i] -'a' + k) % 26) + 'a');
}
else if (isupper(p[i]))
{
printf("%c",((p[i] - 'A' + k) % 26) + 'A');
}
else
{
printf("%c", p[i]);
}
}
printf("\n");
return 0;
}
Update: I got it fixed figured it out...