C language input/output format and additional format specifiers printf (), scanf ()

Source: Internet
Author: User

Printf (), scanf ()

% C --------------- output a character

% D ----------------- output a signed decimal integer

% E (% E) ------------ output a real number of floating-point numbers in the form of normalized exponent. Only 6 digits are valid.

Number, which includes one integer and five decimal places. The exponent part is connected to three digits in total)

% F (% F) ------------- outputs a floating point number. The default format will display 6 decimal places. For float type, valid numbers

Only the first 7 digits, double type, valid digits only the first 16 digits)

Eg: f = 1234567.1230; printf ("% f", & f); only the first seven digits of f = 1234567. xxxx are displayed, and the last digits are random.

% G (% G) ----------- output a floating point number, which can only display the first six valid values

% I ----------------- output a signed decimal integer

% O ---------------- output an octal unsigned integer must be positive or 0)

% P ---------------- output a pointer, that is, an address. The output value must be a pointer or address value)

% X (or % X) --------- output a hexadecimal unsigned integer must be positive or 0)

% S ----------------- output a string

% U ---------------- output an unsigned decimal integer

Additional format specifiers:

Space -------------- when the output value is positive, add a space before it. When the value is negative, add a negative number.

-****************** Align the output results left.

+ ****************** Add a symbol + or-to the output result -)

# **************** If the format is c, d, s, u, the output result is not affected.

* ************** If the format character is g, the decimal point is displayed only when the result contains decimal places.

* **************** If the format character is o, the o will be added before the output result

* *************** If the format character is x, the Ox will be added before the output result

The result of h **************** is output according to the short integer quantity.

L ****************** results will be output according to the Length Integer

Scanf () is used in the same format.

Different:

% [] ---------------- Scan Character Set combination during Input

M ----------------- specifies the width of the input data. m can only be a positive integer.

* ------------------ Indicates that the input will not be assigned to the corresponding variable.

This article is from the "java Notepad" blog, please be sure to keep this source http://6501542.blog.51cto.com/6491542/1287846

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.