Writing Strings to Screen Using printf( ):
We
have used extensively the printf ( ) function with %s format to print strings
to the screen. The format %s can be used to display an array of characters that
is terminated by the null character. For example, the statement
printf ( “%s”,name);
can
be used to display the entire contents of the array name.
We
can also specify the precision with which the array is displayed. For instance,
the specification
%10.4
indicates
that the first four characters are to be printed in a field width of 10 columns.
However,
if we include the minus sign in the specification (e.g., %10.4s), the string
will be printed left-justified.
Post a Comment