Encryption Program help

Apr 23, 2014 at 5:31am
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 May 2, 2014 at 2:15am
Apr 23, 2014 at 8:35am
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)
Apr 23, 2014 at 2:50pm
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 May 2, 2014 at 2:15am
Apr 23, 2014 at 5:58pm
As I said you don't need the for loop, just the word.at(0) statement
Topic archived. No new replies allowed.