int main() {
char myarr[100];
int arrlenght;
cipher(myarr);
decypher(myarr);
}
void cipher(char myarr[]) {
cout << "Enter the chars you want to encrypt and enter '#' to stop " << endl;
for (int i = 0; i < 100; i++) {
cin >> myarr[i];
if (myarr[i] != '#')
continue;
else
break;
}
for (int j = 0; j < sizeof(myarr)/sizeof(myarr[0]); j++) {
cout << static_cast<char>(myarr[j] + 3);
}
}
void decypher(char myarr[]) {
cout << "if you want to Decypher the sentence press '1' if you don't press '2' " << endl;
int input;
cin >> input;
for (int i = 0; i < sizeof(myarr)/sizeof(myarr[0]); i++) {
if (input == 1)
cout << static_cast<char>(myarr[i]);
else
break;
}
}
so this program is supposed to encrypt a word then decrypt it but the problem is it only encrypt and decrypts the 1st 4 chars only .. any idea as to why ?
i know where the error is but i just can't understand what to put in the for loop to fix it. i want a predefined function if there is any or another way to get me the array length after the user is done typing