When printing a string with the s conversion type, the alignment, minimum field width, and precision modifiers still apply, as follows:
printf("String output\n");
printf("Specifier Formatted Value\n");
printf("%%s [%s] everything\n" ,pStr);
printf("%%30s [%30s] everything right-aligned, field=30\n",pStr );
printf("%%.10s [%.10s] truncated to first 10 characters\n",pStr );
printf("%%30.10s[%30.10s] first 10 chars right-aligned, fld=30\n",
pStr);
printf("%%-30.10s [%-30.10s]first 10 chars left-aligned,
field=30\n\n" , pStr);
printf("%%*.*s[%*.*s] use width & precision in argument list\n\n" ,
30 , 10 , pStr);
The string to be printed must be a valid (null-terminated) string. We have seen each of these modifiers before. Unlike integers, however, truncation may occur, depending on the length of...