this post was submitted on 18 Nov 2023
7 points (81.8% liked)

Programming

17022 readers
234 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

This is in C language. When I call rotate() in main, the function returns false for isalpha() even though the string entered for plaintext uses alphabetic characters. Perhaps it's identifying an alphabetic character by its ASCII value ('A' = 65)? I tried to test that out and used (char) with the letter variable in rotate() but it didn't change anything.

PORTION OF MAIN

string plaintext = get_string("plaintext:  ");

    int length = strlen(plaintext);
    char ciphertext[length];

    for (int i = 0; i < length; i++)
    {
        ciphertext[i] = rotate(plaintext[i], key);
    }

ROTATE FUNCTION

char rotate(char letter, int key)
{
    if (isalpha(letter) == true)
    { ...
you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 4 points 10 months ago* (last edited 10 months ago) (1 children)

what language? needs more context

portion of main and function are just titles for me, if that is supposed to contain code

[โ€“] [email protected] 3 points 10 months ago

Sorry. It's in C. Updated post. Yes those are titles. I just included the relevant portions rather than the entire code.