I’ve been learning C and i decided to start a project, Encrypt and Decrypt in ROT13 since i just tought it was the easiest to start with.
I cant seem to figure a way to read the string and change the characters acording to ROT13, i was thinking about a dictionary but i also cant seem to figure that out and use it
I tried LUT but couldnt manage to make it work because everything i found was way too hard for me to understand. I was expecting to just replace every letter with the correspondign one with a lot of Switch or If’s but i just know that its not something good to do. I also cant seem to insert the string with fgets, for some reason it just prints “���x�_�����0�x�_”
#include <stdio.h>
// https://rot13.com/
void Encrypt()
{
char text[50];
printf("Insert the desired text (Maximum of 50 characters): n");
fgets(text, sizeof(text), stdin);
for (int i = 0; i < sizeof(text); i++)
{
printf("%c", text[i]);
}
}
int main()
{
int menu;
while (menu == 0)
{
printf("Choose one of the following options: n");
printf("[1] Encryptn");
printf("[2] Decryptn");
scanf("%i", &menu);
if (menu == 1)
{
Encrypt();
}
if (menu == 2)
{
// Decrypt();
}
}
}
white as void is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.