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.