C-expression assignment self-increment-decrement sizeof comma expression

Source: Internet
Author: User

1. Expression: The expression is called by using an operator to connect the constants, variables, and functions according to certain rules.

Classification: An expression contains relational operators, arithmetic operators, logical operators (P: Expressions must all have return values) ...

Expression statement: The expression is followed by a semicolon ";", which constitutes an expression statement.

2. Assignment operator = (Combination direction: Right to left):

int A, B, C; a=b=c=0;printf ("a=%d,b=%d,c=%c", a,b,c);//output result is a=0,b=0,c=0;

  

1 int A =b=c=1; 2 printf ("a=%d,b=%d,c=%d", a,b,c); 3 // error, because the assignment operator of the direction of the Union: Right to left, 1 is assigned to C, at the moment C is not explained;

3. Self-increase self-reduction x++,++x;

int x=1= x + +;p rintf ("result=%d,x=%d", Result,x ); // The output result is result=0,x=1;
int x=0; result;result=++x;printf ("result=%d,x=%d"  , result,x); // The output result is: result=1,x=1;

4.sizeof

Used to calculate the number of bytes in memory for constants, variables, data types

sizeof (constant/variable), sizeof constant/variable (used in constants or variables, and ellipsis brackets), sizeof (data type)

int  9  sizeof(num); // can be result = sizeof num; printf ("result=%d", result); // output is result=4  sizeof(double);p rintf ("result=%d", result); // The output result is result=8;

5. The evaluation procedure for a comma expression: the value of the expression is evaluated one after the other, and then the value of the last expression is returned. The value as a comma expression.

int A, b,sum,result;a=b=5= (a++,b-a,sum=a+b);p rintf ("a=%d,b=%d,sum= %d,result=%d", A,b,c,result); // output a=6,b=5,c=-1,result=11;

C-expression assignment self-increment-decrement sizeof comma expression

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.