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
Try this:
#include /* printf */
#include /* isalpha isdigit isspace etc */
#define FALSE 0
#define TRUE 1
/* function declarations */
int char_type(char);
main()
{
char ch;
ch = 127;
char_type(ch);
ch = '\b';
char_type(ch);
return 0;
}
int char_type(char ch)
{
if ( iscntrl(ch) != FALSE)
printf("%c is a control character\n", ch);
}
This is a complete program but it only tests for control characters. You could use principles of it, your choice. Just learning too!
See : http://www.tutorialspoint.com/c_standard_library/ctype_h.htm or lookup the functions for the ctype.h header file of the C Standard Library.
It's good that you're getting input. Thanks all for the info. I was just looking up backspace code and found this question.
BTW try '\0' before any char. Not sure what that does but it stops all code after it. Is that like the return 0; line?