Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

C | Input and Output | Question 9

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

What does the following C statement mean? 
 

C




scanf(\"%4s\", str);

(A)

Read exactly 4 characters from console.
 

(B)

Read maximum 4 characters from console.
 

(C)

Read a string str in multiples of 4
 

(D)

Nothing
 


Answer: (B)

Explanation:

Try following program, enter GeeksQuiz, the output would be \”Geek\” 
 

#include <stdio.h>

int main()
{
    char str[50] = {0};
    scanf(\"%4s\", str);
    printf(str);
    getchar();
    return 0;
}

 


Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads