Encryption Program help

I am trying to do the cipher program, but my code seems to encrypt all the characters, how can I just let it convert to just the first one? Thanks.

deleted
Last edited on
From "code seems to encrypt all the characters" I get that you want to encrypt/change just the first character of word. If this is correct then for converting just the first character you dont need this

1
2
3
4
5
for (unsigned i = 0; i < word.size(); i++)
{
    index = word.at(i)- 'a';
    word.at(i) = map.at(index);
}


Just use word.at(0)
so after i changed the code to word.at(0) the program seems to translate the word 5 times.
$ ./a.out
What is the translation map (type 'default' to use default): default

What is the single word to translate: hello

Encrypted word: sello

Encrypted word: hello

Encrypted word: sello

Encrypted word: hello

Encrypted word: sello


my revised code:
deleted
Last edited on
As I said you don't need the for loop, just the word.at(0) statement
Topic archived. No new replies allowed.