Printing of Strings | string handling functions in c programming | cs tring format


Printing of Strings

Printing of Strings
 The format specification for outting strings is of the form %w.ps  where w specifies width for display and p instructs that only the first p characters of string are to be displayed.The display is right
-justified.   The following examples show the effect of a variety of specifications in printing a string
"NEW DELHI  110001", containing 16
(including  blanks). 

Specification & Output:

 1)   %s

N E W D E L H I 1 1 0 0 0 1




2) %20s
L
N E W D E H I 1 1 0 0 0 1


3) %20.10s

N E W D E L H I



4) %.5S

N E W D



5) %-20.10s

N E W D E L H I



6) %5s

N E W D E L H I 1 0 0 0 1

No comments:

Post a Comment