Deep anatomy of C language [Chapter 1]

Source: Internet
Author: User
Tags case statement switch case
1.3.1
static int j;void fun1(void){static int i = 0;i ++;}void fun2(void){j = 0;j++;}intmain(){for(k=0; k<10; k++){fun1();fun2();}return 0;}

Q: Evaluate the values of I and j

 

1.4

Int main () {char a [1000]; int I; for (I = 0; I <1000; I ++) {A [I] =-1-I ;} printf ("% d", strlen (a); // Q: Return 0 ;}

1) according to the above explanation, how are-0 and + 0 stored in the memory respectively?
2), int I =-20;
Unsigned J = 10;
What is the value of I + J? Why?
3) What is the problem with the following code?

unsigned i ;for (i=9;i>=0;i--){printf("%u\n",i);}

1.5.2
What does sizeof (INT) * P mean?
Leave a few questions (the pointer and array will be explained in detail), under the 32-bit system:
Int * P = NULL;
What is the value of sizeof (p?
What about sizeof (* P?
Int A [100];
What is the value of sizeof (?
What about sizeof (A [100? // Pay special attention to this example.
What about sizeof (&?
What about sizeof (& A [0?
Int B [100];
Void fun (int B [1, 100])
{
Sizeof (B); // What is the value of sizeof (B?
}

 

1.8.1
Leave a question: Can I use the continue keyword in the switch case statement? Why?

1.11.1
Note: Read-Only variables modified by const must be initialized at the same time as defined. Why?
Leave a question: can the case statement be followed by a read-only variable modified by const?

1.12
Leave a question: const volatile int I = 10; is there any problem with this line of code? If no, what is the I attribute?

1.14.1
Struct student
{
} Stu;
What is the value of sizeof (Stu?

 

 

1.15.1

Union
{
Int I;
Char A [2];
} * P, U;
P = & U;
P-> A [0] = 0x39;
P-> A [1] = 0x38;
What is the P. I value?

1.15.2

// In x86 systems, what is the output value? # Include <stdio. h> intmain () {int A [5] = {1, 2, 3, 4, 5}; int * ptr1 = (int *) (& A + 1 ); int * ptr2 = (int *) (INT) A + 1); printf ("% x, % x", ptr1 [-1], * ptr2 ); return 0 ;}

 

1.16.2
Leave two questions:
A), enumerative can do things, # can define macros do? If so, why do I still need enumeration?
B) What is the value of sizeof (colorval? Why?

1.17.4
Leave two questions:
1), # define a int [10]
A), a [10] a [10];
B), a [10];
C), int A [10];
D), int;
E), a B [10];
F), a B;
G), a * B [10];
H), A * B;
2), typedef int A [10];
A), a [10] a [10];
B), a [10];
C), int A [10];
D), int;
E), a B [10];
F), a B;
G), a * B [10];
H), A * B;
3), # define a int * [10]
A), a [10] a [10];
B), a [10];
C), int A [10];
D), int;
E), a B [10];
F), a B;
G), a * B [10];
H), A * B;
4), typedef int * A [10];
A), a [10] a [10];
B), a [10];
C), int A [10];
D), int;
E), a B [10];
F), a B;
G), a * B [10];
H), A * B;
5), # define * A int [10]
A), a [10] a [10];
B), a [10];
C), int A [10];
D), int;
E), a B [10];
F), a B;
G), a * B [10];
H), A * B;
6), typedef int (* A) [10];
A), a [10] a [10];
B), a [10];
C), int A [10];
D), int;
E), a B [10];
F), a B;
G), a * B [10];
H), A * B;
7), # define * a * int [10]
A), a [10] a [10];
B), a [10];
C), int A [10];
D), int;
E), a B [10];
F), a B;
G), a * B [10];
H), A * B;
8), typedef int * (* A) [10];
A), a [10] a [10];
B), a [10];
C), int A [10];
D), int;
E), a B [10];
F), a B;
G), a * B [10];
H), A * B;
Determine which definitions are correct and which ones are incorrect. In addition, how do I use int [10] And a [10?

 

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.