[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CPrintF

(C) printf

A function that lets the computer know that it is going to print something on the screen. It can even display variables as well as strings.

It also uses '''escape characters'''. Escape characters start with \ and have another character following it to represent a display (or sound in one case) command. See a list below.

Examples:

  1. include <stdio.h>
int main() { int myInt = 0; char myChar = 'd'; char myString[] ="Hello, world!"; printf("myInt equals: %i\n" ,myInt); printf("myChar equals : %c\n" ,myChar); printf("MyString equals: %s\n",myString); return 0; }


In C++ std::cout is used more commonly.

Escape characters

\n Newline
\r Carriage Return
\a Alert (Beep)
\\ Prints a \ on the screen
\" Prints a " on the screen
\f Formfeed
\t Horizontal tab
\v Vertical tab
\### The octal value where ### is a digit between 0 and 7
\xHH The Hexadecimal value where HH are hexadecimal digits (0 through 9 or a through f)


Conversion specifiers

See specifiers.

'printf' links



last edited (June 11, 2007) by bilderbikkel, Number of views: 6090, Current Rev: 6 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.