I have an error in my code that encrypts and decrypts* a four digit number. It adds 12 to each number in the array then swaps the 1st with the 3rd,swaps the 2nd with the 4th to give me the final answer. The error am getting when i select option 2 after compiling is "Run-Time Check Failure #2 - Stack around the variable 'e' was corrupted." which i don't understand. Please help
#include <iostream>
using namespace std;
int input;
int one;
int two;
int three;
int four;
int p;
int o;
int i;
int u;
int encryption(int one, int two, int three, int four);
int main() {
main:
cout << "Press 1 to Encrypt\n";
cout << "Press 2 to Decrypt \n";
cout << "Press 3 to Exit \n\n";
cin >> input;
while (input != 5) {
break;
}
switch (input) {
case 1:
goto Encryp;
break;
case 2:
goto Decryption;
break;
default:
break;
}
Encryp:
cout << "Enter the number to encrypt: ";
cin >> p;
cin >> o;
cin >> i;
cin >> u;
one = p;
two = o;
three = i;
four = u;
encryption(one, two, three, four);
cout << one << two << three << four;
goto main;
Decryption:
//will be implimented after the fix
getchar();
getchar();
}
int encryption(int one, int two, int three, int four) {
//int q, w, r, t;
int swap1;
int swap2;
int e[3];
e[0] = one;
e[1] = two;
e[2] = three;
e[3] = four;
e[0] = e[0] + 12;
e[1] = e[1] + 12;
e[2] = e[2] + 12;
e[3] = e[3] + 12;
//Swap the 1st with the 3rd
swap1 = e[2];
swap2 = e[3];
e[2] = e[0];
e[0] = swap1;
e[3] = e[1];
e[1] = swap2;
one = e[0];
two = e[1];
three = e[2];
four = e[3];
return one, two, three, four;
}