Delivering a prompt before reading

A command-line C program successfully configures stdout as fully buffered before performing any input or output. It then successfully executes:


C
fputs("Enter station code: ", stdout);


The program will next call fgetc(stdin). It must explicitly deliver any pending prompt characters to the surrounding system before attempting input, without closing stdout or changing its buffering policy.


Complete the following policy using a standard C function name without parentheses, a stream identifier, and a decimal integer return value.


The program should call , passing as its argument. It should proceed to the input operation only if this call returns ; otherwise, it should handle the output failure.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Streams Questions: