Re: PrintF question

From: Gerard Tromp <tromp_at_sanger.med.wayne.edu>
Date: Thu, 17 Dec 1998 15:43:55 -0500
Message-ID: <36796D0B.667215AC_at_sanger.med.wayne.edu>


NeedaHoliday wrote:
>
> Could someone please explain the following printf command.
>
> fprintf(fp, "%-10.10s%-20.20s\n\n", MONTH, hc_inv_per);

                ^^^^^^^^^
%s     -- string conversion

- flag -- left justification
10.10 -- width and precision
          where width is the minimum i.e. padded with blanks
                precision is the maximum, longer strings are truncated

This statement expects two string arguments and the programmer wants at least
10 characters and no more than 10 characters printed, i.e. exactly 10, for the first argument, and exactly 20 characters for the second.

Gerard

-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Gerard Tromp, Ph.D.
CMMG, Wayne State University    vox:	313-577-8773
3116, Scott Hall		fax: 	313-577-5218
540 E Canfield Ave		e-mail: tromp_at_sanger.med.wayne.edu
Detroit, MI 48201                       gtromp_at_cmb.biosci.wayne.edu
Received on Thu Dec 17 1998 - 21:43:55 CET

Original text of this message