C + + learning (vi) output

Source: Internet
Author: User

The output of learning notes (in fact, there is no use, save for yourself to see)

printf for Output Content console black window
printf ("What to Output"); can be any Content
-If you want to output a variable


1. Format placeholder (format placeholder string)
%d receive int type output signed 10 binary
%f is the same with%f or%LF when it receives float type output.
%c receives char type output character
%LF Receive double type
%s Receive String type
%o Output an integral type with unsigned 8 binary
%x%x unsigned 16 binary output an integral type
%u unsigned 10-binary integer (no negative number)
%e decimal in the form of%e index
%g%g Output floating point type (select short width in%e and%lf for output)


2. Control output


2.1 Minimum output width output how many characters
%2d minimum output two-bit digit position not enough space to be filled in (default front blank is the default right alignment) enough to output
356-->%2d


2.2 Decimal digits of precision (only for decimals)
%.9lf. 9 means that precision retains 9 digits
The%M.NLF-->m represents the minimum number of output bits. N means keeping several decimals

2.3 Symbols
+-0 # spaces
+ Front output a symbol%+d
-Control to align left
0 digits not enough front padding 0 for left-justified%03d
# for%o%x has an effect if it is 8 binary final output result plus 0 if it is 16 binary front plus 0x
Space% d If a positive number in front fill a space negative number without tube
\ t can also control the alignment

2.4 Length H means short l for long
Long->long int%ld
Short->short int%HD
Long Long%lld

%f flaot type->%LF doublt

--General format placeholders
%[mark [Minimum width] [precision] [length] Type

Symbol 10 decimal places reserved 2-bit decimal floating point type
%+10.2lf

Single characters enclosed in single quotation marks cannot be split ' M '
A string of multiple characters can be split in double quotes "" "" Hello "
Special characters \+ other content
' \ t ' tab tab
' \ n ' newline
' \ \ ' escape character






printf output

************************************************************/

Practice Code

Effect

C + + learning (vi) output

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.