C-c Primer Plus Read notes

Source: Internet
Author: User

1. Print short, long, long long and unsigned

#include <stdio.h>intMainvoid) {unsignedintUN =3000000000;  ShortEnd = $; LongBig =65537; Long LongVerybig =12345678908642; printf ("un =%u and not%d\n", UN, un);//U=udprintf"end =%hd and%d\n", end, end); printf ("big =%ld and not%hd\n", big, big); printf ("Verybig=%lld and not%ld\n", Verybig, Verybig); return 0;}

Conclusion: Even if the variable itself is an unsigned type, you need to add u when printing, otherwise print according to the signed type; If you print a long type with a short type, the last n bits will be intercepted

2. Eight binary or hexadecimal denotes one character

Char ' \0101 ' ; Char ' \x41 ';

PS: Why use ' \0101 ' instead of 0101 to denote a character, because ' \0101 ' is more articulate with the intent of a character, followed by an escape sequence such as ' \0101 ' can be embedded in a C string, such as "hello!\0101\n"

3.

C-c Primer Plus Read notes

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.