1
Encoder Error
ProgrammerAI (4)

Hey guys, it's me ProgrammerAI. I need help with my encoder. i don't know what is going on. please help. just run it and you will see.

You are viewing a single comment. View All
3
mwilki7 (111)

It looks like a combination of repl not liking infinite loops and
cin >> mode leaving behind a '\n' for the next getline to fail

Try using getline for the cin before the switch case and change mode to a string

volatile int a;
int main()
{
    .
    .
    a = 1;
    while(a == 1)
    {
        .
        string mode;
        getline(cin, mode, '\n')
        switch(mode[0])
        ...
    }
1
ProgrammerAI (4)

@mwilki7 I tried and i get a logic error

1
mwilki7 (111)

@ProgrammerAI
Looks like your encode function was using char arrays instead of strings.
Try this:

void encode() {
	string message;
	cout << "Enter message: ";
	getline(cin, message);
	string newMessage = encoder.hello(message, add);
	cout << newMessage << endl;
}
1
mwilki7 (111)

@ProgrammerAI try replacing your encode function with the one in the post above

1