Results 1 to 1 of 1
I have the following code. As far as I am concerned, I think each time I input a character (such as 'b') I got a 'b' and 'LF' from terminal.
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-26-2009 #1Just Joined!
- Join Date
- Aug 2009
- Posts
- 2
How to use VERASE of struct termios?
I have the following code. As far as I am concerned, I think each time I input a character (such as 'b') I got a 'b' and 'LF' from terminal.
But if I set VERASE, which means "Causes the terminal driver to delete the last character on the line", The 'LF' should be deleted by the terminal. But it's not the truth.
What's wrong? How to demonstrate the affect of VERASE if it's set?
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <assert.h>
int main()
{
char str[10] = {0};
char c;
int rlt;
FILE* in;
struct termios attr;
if(!isatty(fileno(stdout)))
{
assert(0);
}
in = fopen("/dev/tty", "r");
tcgetattr(fileno(in), &attr);
attr.c_cc[VERASE] = 1;
rlt = tcsetattr(fileno(in), TCSANOW, &attr);
do{
puts("input char");
c = getchar();
putchar(c);
}while(c!='q');
}


Reply With Quote
