how to check for the “backspace” character in C

后端 未结 5 510
天涯浪人
天涯浪人 2020-11-30 08:01

I\'d like to know how to check if a user types the \"backspace\" character.

I\'m using the getch() function i.e. \"key = getch()\" in my C program and i

5条回答
  •  粉色の甜心
    2020-11-30 08:12

    You didn't say which library the getch() function comes from (it isn't part of the C standard), but if it's the one from ncurses you can check the value of key against KEY_BACKSPACE.

提交回复
热议问题