Tengo el siguiente codigo:
Código
char buf; struct termios old = {0}, new = {0}; if (tcgetattr (STDIN_FILENO, &old) < 0) return -1; new = old; new.c_lflag &= ~ICANON; new.c_cc[VMIN] = 1; new.c_cc[VTIME] = 0; if (tcsetattr (STDIN_FILENO, TCSANOW, &new) < 0) return -1; if (read (STDIN_FILENO, (char *)&buf, 1) < 0) return -1; if (tcsetattr (STDIN_FILENO, TCSANOW, &old) < 0) return -1; return buf; } int main () { ... }
No entiendo por qué debo poner fflush despues de haber impreso por pantalla el "Introduce un caracter". Es decir, ¿por qué no lo imprime en primera instancia?
Gracias de antemano.





Autor




En línea


