Hi, me again
I am trying to write a program that loops an input until the escape key is pressed. But how do you put a single char into the input buffer so when the program requests a input the char will be displayed and removable by backspace key? Below is the basic what I have come so far but the problem is that “cin.putback(c);” does neither display the char “c” nor is it removable for the user, when pressing backspace key. I could add “cout << c;” but that only solves one problem, what do I need to do to make the char editable/removable for user when inputing?
Code:char c; while (1) { c = getch(); switch (c) { case 27: // Escape key is pressed return 0; case 13: // Enter key is pressed //... break; default: // Some other key is pressed cin.putback(c); // Place char c into the input buffer, // but it won't be displayed nor editable when input requested. cin.getline(Text, 256); // request input from user, // the char c will be included in Text when user has finished input. //... } }



LinkBack URL
About LinkBacks



