C Language Study Notes

Source: Internet
Author: User

1. logical operator | & if the subexpression on the left of the operator determines the final result, the subexpression on the right will not be calculated, for example, if (d! = 0 & n/d> 0) {/* average is greater than 0 */} if (p = NULL | * p = '\ 0 ') {/* no string */} in the first example, if there is no short circuit, once d = 0, the expression on the right will be divided by 0-the system may crash; in the second example, if p is a null pointer, the expression on the right references an empty address, which may cause system crash. 2. There is no uniform rule on the order of values of real parameters in C language. However, the order of values of function parameters in most systems is from right to left. I = 3; printf ("% d, % d \ n", I, I ++); the output result is: 4, 3, I ++ and ++ I operators I = 3; j = (++ I) + (++ I ); printf ("j = % d, I = % d \ n", j, I); the output result is: j = 16, I = 6 (gcc compiler) Different compilers, the results may be different. When computing j = (a + B) + (c + d) + (e + f), the computer first calculates (a + B) + (c + d ), and store the results (for example, stored in j), and then compute j + (e + f) = j; the computer only has one I. When the second I is calculated, the first I has changed. Int I = 1, j = 1, k; I = (I ++) + (++ I); k = (j ++) + (++ j ); printf ("I = % d, j = % d, k = % d \ n", I, j, k); output result: I = 5, j = 3, k = 4 (gcc compiler)

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.