This article focuses on two parts: Symbol overloading and computing priority. These two problems are very common and cumbersome. I guess most people choose to ignore the content of this chapter when learning. However, during interviews, I often take this test, because it is a "proficient" name.
In C, there are symbol overloading. symbol Overloading is embodied in the context of the program. Different symbols have different meanings. For example, "*" has three meanings: declare pointer, resolve pointer, and multiply number. C expert programming summarizes all the symbol overloading to clarify the C language scope rules:
Priority
What should I do if I encounter a bunch of operators in practice? Best tips:
However, to be proficient in C, you must be able to understand the code written by others. Therefore, some common knowledge of priority needs to be consolidated. NOTE: For the Declaration priority, refer to subsequent blog posts.
Summarize the order:
- Elementary Operation () []->.
- Single Object operation
- The arithmetic operation first multiplication and division, and then addition and subtraction
- Shift
- The link size is equal to or equal
- The bitwise is the same as the logic.
- Logic (not including !, Because it is a single object)
- Condition
- Assignment
- Comma
In general, the combination is used in combination with the priority, but there are a lot of messy representations in common textbooks, which are dazzling. On the whole, all the combination rules can be summarized into the following two sentences:
- All of them have a right combination. What is a value assignment? What I understand is "Is it true"
- The rest are left-bound.
Give an example of my understanding
1. Change
- ! P: this is a logical non-operator. The p value is changed during the call.
- * P: the pointer operator. Actually, calling p refers to something, not p itself. Actually, the call has changed.
- & A: Get the address. The actual call is the address of a, not a. The call has changed.
- Sizeof a: When the call is made, the length of a is returned, instead of a itself. The call has changed.
The above changes are actually part of the process.
2. Value Change
- ++ I: The I value changes after the call.
- Is? True: false: The returned results of the call are uncertain. In a sense, the call is a "changed" thing. Thank you for your attention.
- Value assignment operator: =, + =, and so on. After calling, the value changes.
Conclusion: even more, we should follow our intuition and remember the things that do not take the ordinary path. In addition, I think