Decryption program not working properly

Hey, I have a program that needs to decrypt things with the following cipher:
'!' ­> 'a'
'^' ­> 'b'
'&' ­> 'c'
'*' ­> 'd'
'@' ­> 'e'
'(' ­> 'f'
')' ­> 'g'
'­' ­> 'h'
'#' ­> 'i'
'_' ­> 'j'
'=' ­> 'k'
'+' ­> 'l'
'[' ­> 'm'
'{' ­> 'n'
'$' ­> 'o'
']' ­> 'p'
'}' ­> 'q'
';' ­> 'r'
':' ­> 's'
',' ­> 't'
'%' ­> 'u'
'<' ­> 'v'
'.' ­> 'w'
'>' ­> 'x'
'/' ­> 'y'
'?' ­> 'z'
Only some of them I currently have implemented, however it would be nice if someone could get me code with all of them implemented, also my current code doesn't work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  #include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    vector<char> normalV(26);
    vector<char> cipherV(26);
    normalV.at(0) = 'n';
    normalV.at(1) = 'c';
    normalV.at(2) = 'e';
    normalV.at(3) = 'i';
    cipherV.at(0) = '{';
    cipherV.at(1) = '&';
    cipherV.at(2) = '@';
    cipherV.at(3) = '#';
    string toDec = "";
    string beenDec = "";
    
   // normalV.at(0) = 'n'; cipherV.at(0) = '{';
    
    // Get secret message
    do {
        cout << "Enter a secret message: ";
        getline(cin, toDec);
    } while (toDec.length() == 0);

    beenDec = toDec;
 for (int i = 0; i <= (toDec.length() - 1); ++i) {
    // Decrypt secret message
    if (toDec.at(i) == cipherV.at(0)) {
        beenDec.at(i) = normalV.at(0);
    }
// for (int i = 0; i < 25; ++i) {
  //   if (toDec.at(i) == cipherV.at(0)) {
    //    beenDec.at(i) = normalV.at(0);
   // }
//}

}
    
    cout << "Decrypted message: " << beenDec << endl;
    
    return 0;
}
Great googly-moogly OP! Use a map! : http://www.cplusplus.com/reference/map/map/
This sort of thing is exactly what they are there for.
Sorry, this is graded, and I haven't seen that concept yet, so...
Topic archived. No new replies allowed.