C中的sizeof和三元运算符 C中的赋值运算符 C中的运算符优先级 C中的sizeof和三元运算符 #include <stdio.h> main() { int a = 4; short b; double c; int* ptr; /* example of sizeof operator */ printf("Line 1 - Size of variable a = %d\n", sizeof(a) ); printf("Line 2 - Size of variable b = %d\n", sizeof(b) ); printf("Line 3 - Size of variable c= %d\n", sizeof(c) ); /* example of & and * operators */ ptr = &a; /* 'ptr' now contains the address of 'a'*/ printf("value of a is %d\n", a); printf("*ptr is %d.\n", *ptr); /* example of ternary operator */ a = 10; b = (a == 1) ? 20: 30; printf( "Value of b is %d\n", b ); b = (a == 10) ? 20: 30; printf( "Value of b is %d\n", b ); } C中的赋值运算符 C中的运算符优先级