If I go
Code:
char* input_char = "";
while(input_char != "exit") cin >> input_char;
it never exits the loop, even if I type exit. If I cout input_char every time, it looks like it should work.
Code:
while(input_char != "exit\0") cin >> input_char;
doesn't work either, nor does
Code:
while(input_char != (char*)"exit") cin >> input_char;
or
Code:
while(input_char != (char*)"exit\0") cin >> input_char;
I have no idea why. The only way I have found to make this work properly is to treat input_char as an array and go
Code:
while(!(input_char[0]=='e'&&input_char[1]=='x'&&input_char[2]=='i'&&input_char[3]=='t'&&input_char[4]=='\0') cin >> input_char;
I've also tried casting input_char to an (int) and comparing it to the (int) version of "exit", but for some reason the (int) version of input_char is the same, no matter what my input.
I've been having this problem for a while and I'm not sure why.. why?
Thanks