C ++ snacks: % i64d is used in wprintf to format and output Longlong

Source: Internet
Author: User
ArticleDirectory
    • Longlong
    • Example
    • References

WriteProgramBecause a large integer is required, the Longlong type is required:

 
Longlong nlarge;

However, during formatting, you do not know what characters should be used. % d and % l cannot be used.

 

Longlong

Longlong is actually int64 type. In winnt. H, you can see:

 
Typedef _ int64Longlong;

Therefore, if you want to output the data, you need to see what format characters _ int64 uses. By checking msdn, we found that:I64.

In formatting the output, you also need to combine a D, that is, % i64d. For unsigned ulonglong, It is % i64u.

 

Example
Longlong nlarge= 9999999888;Wprintf(L"Longlong = % i64d \ n",Nlarge);Ulonglong ularge= 99999998777;Wprintf(L"Ulonglong = % i64u",Ularge);

The output is as follows:

Longlong = 9999999888.

Ulonglong = 99999998777

 

References
 
Format specification fields: printf and wprintf Functions
 
Http://msdn.microsoft.com/en-us/library/tcxf1dw6 (vs.71). aspx

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.