Can we specify variable field width in a scanf() format string? If possible how?

C Programming Language >   Constant in C Language >   About Java Tutorial  

Long Question

2691


Answer:

All field widths are variable with scanf(). You can specify a maximum field width for a given field by placing an integer value between the % and the field type specifier. (e.g. %64s). Such a specifier will still accept a narrower field width. The one exception is %#c (where # is an integer). This reads EXACTLY # characters, and it is the only way to specify a fixed field width with scanf().


This Particular section is dedicated to Question & Answer only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.




Join Our telegram group to ask Questions

Click below button to join our groups.