Why is the output of this program not getting underlined
int main() {
tgetent(NULL, getenv("TERM"));
tputs(tgetstr("us", NULL), 1, &putchar);
write(1, "Hello world!\n", 13);
tputs(tgetstr("ue", NULL), 1, &putchar);
}
but this is?
int main() {
tgetent(NULL, getenv("TERM"));
tputs(tgetstr("us", NULL), 1, &putchar);
puts("Hello world!");
tputs(tgetstr("ue", NULL), 1, &putchar);
}
EDIT
The issue is, indeed, about buffer management! If I add fflush
, the string is properly underlined
int main() {
tgetent(NULL, getenv("TERM"));
tputs(tgetstr("us", NULL), 1, &putchar);
fflush(stdout);
write(1, "Hello world!\n", 13);
tputs(tgetstr("ue", NULL), 1, &putchar);
}