Search⌘ K
AI Features

Hello, stdin

Discover how to handle standard input in C programming by analyzing puzzle code. Learn to predict outputs and improve your understanding of input processing in C.

We'll cover the following...

Puzzle code

Read carefully the code given below:

C
#include <stdio.h>
int main()
{
char buffer[BUFSIZ]; /* BUFSIZ is a constant defined in stdio.h */
setbuf(stdout, buffer);
puts("Wait for it!");
puts("Wait for it!");
puts("Now!");
getchar();
puts("Whew!");
return(0);
}

Your task: Guess the output

Attempt the following test to assess your understanding.

Technical Quiz
1.

What will be the output of the following code before and after pressing the “Enter” key?

A.

Before pressing Enter:
Wait for it!
Wait for it!
Now!

After pressing Enter:

Whew!

B.

Before pressing Enter:
Wait for it!
Wait for it!
Now!
Whew!

After pressing Enter:
Nothing new is printed.

C.

Before pressing Enter:
Nothing is printed.

After pressing Enter:
Wait for it!
Wait for it!
Now!
Whew!

D.

Before pressing Enter:
Wait for it!
Wait for it!

After pressing Enter:

Now!
Whew!


1 / 1

Let's discuss the code and output together in the next lesson.