Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

backspace in command line

Status
Not open for further replies.

neonep

Programmer
Jun 26, 2003
34
I am writing a command line interpreter and I just need to figure out how I would make it possible for the users to use backspace to erase characters in the input buffer.
So if they mistakenly type in "adc" then they could use backspace to make it "ad" and then continue to make it "add". Any help is appreciated.
 
Which operating system and compiler are you using?


--
 
I am using the lcc compiler in windows OS.
 
Generally speaking backspace is actually two chars long on most *nix systems (though I don't know how DOS (windows) does this). There is a thread about this sort of thing in C++: Unix forum thread, but with doss you may just beable to look for the backspace char's ascii code (8 in Decimal).

The trick is that you need to be able to read each char when you get it, so you'll either have to find a way to put the counsole into "raw" mode or use curses to get each char when it is typed as opposed to when a newline is encountered ("\n" or on DOS/Windows "\n\r").
 
Does your compiler provide these functions as part of the APIs available to you?

Or you could look to see if there is a port of the "ncurses" terminal package for your compiler.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top