Question
I am trying to return the decrypted message and pass it into a print function. I don't know what the error is. Please help! Header
I am trying to return the decrypted message and pass it into a print function.
I don't know what the error is. Please help!
Header & respective functions:
class Decoder { private: char *encrypted; bool status; int size; char message[];
public: Decoder(string file, int maxBytes); bool getStatus(); char decrypt(); void print(); };
char Decoder::decrypt() { char key[] = { 'i','z','t','o','h','n','d','b','e','q','r','k','g','l','m','a','c','s','v','w','f','u','y','p','j','x' }; if (getStatus()) { char message[]; for (int i = 0; i < size; i++) { message[i] = key[(int)encrypted[i] - 97]; } } else { cout << "Message not decrypted." << endl; }
return message; }
void Decoder::print() { cout << "Decrypted message: " << decrypt() << endl; }
int main() { Decoder obj("encrypted.txt", 26); obj.decrypt(); obj.print(); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started