I'm trying to write a function that reads keystrokes using the NCURSES library's "getstr(str )" function (where "str" is a C-style string, and it modifies the value of it directly). However, my code does not ever cause the program to exit, and even when typing exactly the word "quit," no backspace or anything, it gives me the "Unknown command" message. I'm writing in C++ using the G++ compiler on Kubuntu Linux 7.04.
[code=cpp]display::clear_ messages(); // Clear the top line of the screen
echo(); // Show the characters being typed
cbreak(); // Wait for <enter>
char text[20];
getstr(text); // changes text[20] directly
noecho(); // Don't show characters
raw(); // Give me the keystrokes directly
if (text == "quit") {
exit(0);
} else {
display::messag e(display::blan k_line);
move(0,0); // Move to top line
printw("Unknown command '%s'",text); // works like printf()
}[/code]
Thanks in advance!
[code=cpp]display::clear_ messages(); // Clear the top line of the screen
echo(); // Show the characters being typed
cbreak(); // Wait for <enter>
char text[20];
getstr(text); // changes text[20] directly
noecho(); // Don't show characters
raw(); // Give me the keystrokes directly
if (text == "quit") {
exit(0);
} else {
display::messag e(display::blan k_line);
move(0,0); // Move to top line
printw("Unknown command '%s'",text); // works like printf()
}[/code]
Thanks in advance!
Comment