Hi, I need help with my program. How can I fix my compiler error on line 12 of me code? It's not working for some reason. May I have feedback please?
This is the problem:
Your country is at war and your enemies are using a secret code to communicate
with each other. You have managed to intercept a message that
reads as follows:
:mmZ\dxZmx]Zpgy
Write a program that decrypts the intercepted message. You only know
that the key used is a number between 1 and 100. Your program should
try to decode the message using all possible keys between 1 and 100.
When you try the valid key, the message will make sense. For all other
keys, the message will appear as gibberish.
This is the problem:
Your country is at war and your enemies are using a secret code to communicate
with each other. You have managed to intercept a message that
reads as follows:
:mmZ\dxZmx]Zpgy
Write a program that decrypts the intercepted message. You only know
that the key used is a number between 1 and 100. Your program should
try to decode the message using all possible keys between 1 and 100.
When you try the valid key, the message will make sense. For all other
keys, the message will appear as gibberish.
Code:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void input(char message[100], int& key);
vector<char> encrypt(char message[100], int key);
int main()
{
input(message[100], key);
vector<char> encrypt(char message[100], key);
return 0;
}
void input(char message[100], int& key)
{
cout << "Please enter an encrypted message: \n";
cin.getline(message,100);
}
vector<char> encrypt(char message[100], int key)
{
int counter;
char output[100];
for(key = 1; key <= 100; key++)
{
for(counter = 0; message[counter]! = '\0' ; counter++)
{
if(message[counter] - key < 32)
output[counter] = message[counter] - key - 32 + 127;
else
output[counter] = message[counter] - key;
}
cout << "Decrypted message using Key" << key << " : ";
cout << output << endl;
}
}
Comment