Printf format string

Printf (English print formatted ) is a very common output function, derived from the C programming language.

The function accepts a string containing text and formatting instructions and one or more values ​​. The string is output while the values ​​inserted in the appropriate format ( spelling).

As a rule, from output to standard output, it exists beyond the variant fprintf for output on any output stream (eg, the standard error output or a file).

Use in C / C

Hello world program in C using printf.

# include   int main ( void) {      printf (" Hello world \ n " );      return 0; } The function consists of a format string and the arguments actually issued.

The following placeholders in the format string to be used for the various data types:


In the Java programming language was introduced in 2004 with version 5 similar functionality. There, the two classes and have since appropriate methods named format. There is also a separate class and a static method java.util.Formatter format standard class string, process the appropriate formatting patterns and generate formatted strings.