0

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...

1
  • Turns out... Spelling is important when coding... Dec 17, 2019 at 7:40

1 Answer 1

0

Can you mark it as answered. If you want answer your own question explaining the solution or just mark this as the answer. Just keeping up with forum maintenance 🙃

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .