Ceaser Cipher Decryption

Hello, my purpose is converting bcç to abc (1 time shifting with decryption) you can wonder what is "ç".
"ç"is one of the Turkish alphabet letter and I would like to conver letter "b" to a, letter "c" to "b"and letter "ç" to "c" can you help me for this code. Thanks.
It depends on order of characters in your local codepage. Try to do:
1
2
3
char n = 'c';//Turkish c, not english.
++n;
std::cout << n;

if it gives you a 'ç', everything is fine. If not, you will have to go the hard way.
Output is "d" not "ç" :(

A friend said " I would recommend you to use a substitution table. Create an array of 256 characters (one for each code-point in your character encoding table) and fill each code-point with the letter which is supposed to be used instead of it. Then iterate the input text and replace each character by looking it up in that array."

but I didnt understand what he means :(
For example with digits:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

int main ()
{
    char original[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    char substitute[10] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
    char line[] = "123";
    int index = 0;
    while(line[index])
    {
        int i = -1;
        while(line[index] != original[++i]) //finds index of character in original array
            ;
        line[index++] = substitute[i]; //Replaces it with corresponding character from substitute array
    }
    std::cout << line;
}
Last edited on
Thank u so much I understand now.
Topic archived. No new replies allowed.