C # To C ++ -- C # The Path to C ++ Transformation (1) C

Source: Internet
Author: User

C # To C ++ -- C # The Path to C ++ Transformation (1) C

It takes a lot of determination to study full-time. Some people may say why they don't study while working. Indeed, everyone has their own path. I chose to move to the bottom layer of technology and quickly. Therefore, after a long period of consideration, I still choose to study full-time.


To learn C/C ++, you must first learn C.

Constant:

The constants of C are different from those of C #. Of course, the C # syntax is encapsulated by Microsoft. The constant of C is defined by # define, that is, the macro in C. Its essence is to replace the text in the compiler pre-compilation phase. Replace the macro defined by # define with the position where the macro is used.

In C #, const is the keyword that defines constants. However, in C, const defines Read-Only variables and must be assigned values at the time of definition. Otherwise, no value can be assigned.


++ And --:

Auto-increment and auto-increment.

Int I = 10; int a = I ++ I; I = 10; int B = ++ I + I;

In the above Code, a = 21, B = 22 in C #, Because I ++ is in C #, the auto-increment operation takes effect the next time the variable is used.


In C, the Code a = 20 B = 22

What is different from C # Is that I ++ is auto-incrementing after the expression is executed.

That is to say, I ++ I is equal to 10 in C. Because the expression has not been executed, the I value is still 10. So I ++ I is actually 10 + 10



Long

In C, the long type is also 4 bytes in 32-bit operating system and int type. In most 64-bit operating systems, it is 8 bytes. However, long is 8 bytes long.


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.