Mega Code Archive

 
Categories / C Tutorial / Stdio h
 

Printf

Item Value Header filestdio.h Declarationint printf(const char *format, ...); Functiondisplay message by format. Returnthe number of characters actually printed. A negative value indicates failure. #include <stdio.h> int main(void){  printf("Hi %c %d %s", 'c', 10, "there!"); } Hi c 10 there! The printf() Format Specifiers CodeFormat %aHexadecimal output in the form 0xh.hhhhp+d (C99 only). %AHexadecimal output in the form 0Xh.hhhhP+d (C99 only). %cCharacter. %dSigned decimal integers. %iSigned decimal integers. %eScientific notation (lowercase e). %EScientific notation (uppercase E). %fDecimal floating point. %FDecimal floating point (C99 only; produces uppercase INF, INFINITY, or NAN when applied to infinity or a value that is not a number. The %f specifier produces lowercase equivalents.) %gUses %e or %f, whichever is shorter. %GUses %E or %F, whichever is shorter. %oUnsigned octal. %sString of characters. %uUnsigned decimal integers. %xUnsigned hexadecimal (lowercase letters). %XUnsigned hexadecimal (uppercase letters). %pDisplays a pointer. %nThe associated argument must be a pointer to an integer. This specifier causes the number of characters written (up to the point at which the %n is encountered) to be stored in that integer. %%Prints a percent sign.