Unformatted text preview: COMP.1010 printf F18 -‐ Dr. Lin Facts about printf • is a function, the function name is printf • the function displays program output, on screen • in the standard input/output library called stdio.h (#include <stdio.h>) • \n to print a new line • \t to print a tab • \\ to print \ (backslash) • \” to print “ (double quote) • %% to print % (percentage sign) • %s: placeholder for a string, the string will be enclosed in “ ” • %d: placeholder for integer • %nd: print in integer at least n width, right-‐justified • %-nd: print in integer at least n width, left-‐justified • %c: placeholder for a single character, the actual character will be enclosed in ‘ ’ • %f: placeholder for floating numbers (double precision numbers) • %g: placeholder for floating numbers, with shorter formats • %m.nf: m is the total width of the number (including . or -‐ sign), right-‐
justified; n is the precision of the decimal part • %-m.nf: same as above except left-‐justified ...
View Full Document
- Fall '15