printf: display message by format : printf « stdio.h « C / ANSI-C

Home
C / ANSI-C
1.assert.h
2.Console
3.ctype.h
4.Data Structure Algorithm
5.Data Type
6.Development
7.File
8.Function
9.Language Basics
10.Macro Preprocessor
11.Math
12.math.h
13.Memory
14.Pointer
15.setjmp.h
16.signal.h
17.Small Application
18.stdio.h
19.stdlib.h
20.String
21.string.h
22.Structure
23.time.h
24.wctype.h
C Tutorial
C++
C++ Tutorial
Visual C++ .NET
C / ANSI-C » stdio.h » printfScreenshots 
printf: display message by format


    

//Header file:     #include <stdio.h>  
//Declaration:     int printf(const char *format, ...); 
//Return:          the number of characters actually printed. A negative value indicates failure. 

// The printf() Format Specifiers
    
//Code Format
//%a:  Hexadecimal output in the form 0xh.hhhhp+d (C99 only). 
//%A:  Hexadecimal output in the form 0Xh.hhhhP+d (C99 only). 
//%c:  Character. 
//%d:  Signed decimal integers. 
//%i:  Signed decimal integers. 
//%e:  Scientific notation (lowercase e). 
//%E:  Scientific notation (uppercase E). 
//%f:  Decimal floating point. 
//%F:  Decimal 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.) 
//%g:  Uses %e or %f, whichever is shorter. 
//%G:  Uses %E or %F, whichever is shorter. 
//%o:  Unsigned octal. 
//%s:  String of characters. 
//%u:  Unsigned decimal integers. 
//%x:  Unsigned hexadecimal (lowercase letters). 
//%X:  Unsigned hexadecimal (uppercase letters). 
//%p:  Displays a pointer. 
//%n:  The 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. 

  


#include <stdio.h>

int main(void){
 printf("Hi %c %d %s"'c'10"there!");
}



         
/*
Hi c 10 there!*/ 
           
       
Related examples in the same category
1.Output char
2.print the ASCII code for c
3.print character with ASCII 90
4.print ivalue as octal value
5.print lower-case hexadecimal
6.print upper-case hexadecimal
7.minimum width 1
8.minimum width 5, right-justify
9.minimum width 5, left-justify
10.33 non-null, automatically
11.31 non-null, automatically
12.minimum 5 overridden, auto 33
13.minimum width 38, right-justify
14.minimum width 38, left-justify
15.default ivalue width, 4
16.printf ivalue with + sign
17.minimum 3 overridden, auto 4
18.minimum width 10, right-justify
19.minimum width 10, left-justify
20.right justify with leading 0's
21.using default number of digits
22.minimum width 20, right-justify
23.right-justify with leading 0's
24.minimum width 20, left-justify
25.minimum width 19, print all 17
26.prints first 2 chars
27.prints 2 chars, right-justify
28.prints 2 chars, left-justify
29.using printf arguments
30.width 10, 8 to right of '.'
31.width 20, 2 to right-justify
32.4 decimal places, left-justify
33.decimal places, right-justify
34.width 20, scientific notation
35.printf %s for string
36.printf %d for integer
37.printf %ld for long integer number
38.printf %10d, %10.f
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.