ungetc() Function | C Programming Tutorial

preview_player
Показать описание

Examples of situations that could use ungetc() to help:

Рекомендации по теме
Комментарии
Автор

You are seriously an amazing teacher. Every time I need to understand something better in C I specifically search for that topic in your channel first.

nathanaelmoh
Автор

I'm trying to write a program that reads a fixed number of characters from STDIN...but I *_don't_* want to press the return key after I've entered the characters...is it possible to use ungetc to append a newline character to the end of the string as a means of "fooling" the program into thinking the return key has been pressed?
EDIT. I've figured it out...it's not a question of ungetc. You have to manipulate settings of the termios structure. In particular, you have to go into "non canonical" input mode and set the MIN member to the number of characters you want to input.
It took a bit of digging, but I got there in the end! 😁

bettyswunghole
visit shbcf.ru