11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Library FunctionsPRINTF, VPRINTFSynopsis#include int printf (const char * fmt, ...)#include #include int vprintf (const char * fmt, va_list va_arg)DescriptionThe printf() function is a formatted output routine, operating on stdout. There are correspondingroutines operating on a given stream (fprintf()) or into a string buffer (sprintf()). The printf() routineis passed a format string, followed by a list of zero or more arguments. In the format string areconversion specifications, each of which is used to print out one of the argument list values.Each conversion specification is of the form %m.nc where the percent symbol % introducesa conversion, followed by an optional width specification m. The n specification is an optionalprecision specification (introduced by the dot) and c is a letter specifying the type of the conversion.A minus sign (’-’) preceding m indicates left rather than right adjustment of the converted valuein the field. Where the field width is larger than required for the conversion, blank padding is performedat the left or right as specified. Where right adjustment of a numeric conversion is specified,and the first digit of m is 0, then padding will be performed with zeroes rather than blanks. Forinteger formats, the precision indicates a minimum number of digits to be output, with leading zerosinserted to make up this number if required.A hash character (#) preceding the width indicates that an alternate format is to be used. Thenature of the alternate format is discussed below. Not all formats have alternates. In those cases, thepresence of the hash character has no effect.The floating point formats require that the appropriate floating point library is linked. Fromwithin HPD this can be forced by selecting the "Float formats in printf" selection in the optionsmenu. From the command line driver, use the option -LF.If the character * is used in place of a decimal constant, e.g. in the format %*d, then one integerargument will be taken from the list to provide that value. The types of conversion are:fFloating point - m is the total width and n is the number of digits after the decimal point. If n is176

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!