Why not be proficient in C? 02 symbol overload in C language, priority

Source: Internet
Author: User

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:

Symbol Meaning
















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

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.