c - Meaning of "." in printf -


i reading classic k&r , encountered following syntax:

printf("%.*s",max,s); 

what meaning of "." here?when don't apply "." here,then whole string printed,but when don't apply "." ,atmost max characters printed.i thankful if explain this.

in %.*s, .* limits number of bytes written. if written numeral included, such %.34s, numeral limit. when asterisk used, limit taken corresponding argument printf.

from c 2011 (n1570) 7.21.6.1 4, describing conversion specifications fprintf et al:

an optional precision gives … maximum number of bytes written s conversions. precision takes form of period (.) followed either asterisk * (described later) or optional decimal integer; if period specified, precision taken zero.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -