C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - Yes / No Questions (Q.No. 4)
Can we specify a variable filed width in a scanf() format string?
Answer: Option
In scanf() a * in a format string after a % sign is used for the suppression of assignment. That is, the current input field is scanned but not stored.
6 comments Page 1 of 1.

Nazima Khan said:   5 years ago

Thank you so much.

Sawant said:   10 years ago
In scanf(), we can't use variable width specifier, we can only use like:


If you enter 12345678, the scanf simply scan the first 4 digits (ie) 1234 only.

But we can use variable width specifiers in printf():


4 is the width of the integer a.

Dev said:   1 decade ago
What is the correct answer?

Mini said:   1 decade ago

Thank you so much.

Pruthvi said:   1 decade ago
Answer is YES. We can specify variable field width.


// will only take digits chars at run time.

Nishant said:   1 decade ago
Can anybody please explain me the answer.

Post your comments here:

Your comments will be displayed after verification.