printf : printf « stdio.h « C Tutorial

Home
C Tutorial
1.Language
2.Data Type
3.String
4.printf scanf
5.Operator
6.Statement
7.Array
8.Function
9.Structure
10.Pointer
11.Memory
12.Preprocessor
13.File
14.Data Structure
15.Search Sort
16.Wide Character String
17.assert.h
18.ctype.h
19.math.h
20.setjmp.h
21.signal.h
22.stdio.h
23.stdlib.h
24.string.h
25.time.h
26.wctype.h
C / ANSI-C
C++
C++ Tutorial
Visual C++ .NET
C Tutorial » stdio.h » printf 
22.24.1.printf
ItemValue
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.


22.24.printf
22.24.1.printf
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.