Command: printf
  
Syntax: 
  printf(fn, st, x)
  
Description: 
  Print x, to file or device fn, using format string st. If x is 
  an atom then a single value will be printed. If x is a sequence, 
  then formats from st are applied to successive elements of x. 
  Thus printf always takes exactly 3 arguments. Only the length of 
  the last argument, containing the values to be printed, will 
  vary. The basic formats are: 
  
  %c - print a single character
  %d - print an atom as a signed decimal integer
  %u - print an atom as unsigned decimal integer
  %x - print an atom as a hexadecimal integer
  %o - print an atom as an octal integer
  %s - print a sequence as a string of characters
  %e - print an atom as a floating point number with exponential 
  notation
  %f - print an atom as a floating-point number with a decimal
  point but no exponent
  %g - print an atom as a floating point number using either
  the %f or %e format, whichever seems more appropriate
  %% - print the '%' character itself
  
  Field widths can be added to the basic formats, e.g. %5d, or 
  %8.2f. The number before the decimal point is the minimum field
  width to be used. The number after the decimal point is the 
  precision to be used.
  
  If the field width is negative, e.g. %-5d then the value will be 
  left-justified within the field. Normally it will be right-
  justified. If the field width starts with a leading 0, e.g. %08d
  then leading zeros will be supplied to fill up the field. If the
  field width starts with a '+' e.g. %+7d then a plus sign will be
  printed for positive values. 
  
Example 1: 
   rate = 7.875
      printf(myfile, "The interest rate is: %8.2f\n", rate)
      
      The interest rate is:     7.88
 
Example 2: 
   name="John Smith"
      score=97
      printf(1, "%15s, %5d\n", {name, score})

           John Smith,    97
           
Comments: 
  Watch out for the following common mistake:
  
  printf(1, "%s", name)
  
  This will print only the first character of name, as each element 
  of name is taken to be a separate value to be formatted. You must 
  say this instead:
  
  printf(1, "%s", {name})
  
  Now, the third argument of printf is a one-element sequence
  containing a single value to be formatted.
  
See Also: 
  sprintf, puts, open 
  

