Joke Collection Website - Joke collection - It's just that there is something wrong with the pointer array in C language.
It's just that there is something wrong with the pointer array in C language.
Type of A: int [4][ 10], A is a one-dimensional array with four elements, and each element is a one-dimensional array with 10 int data.
Essentially, C language has no multidimensional arrays! Please remember.
So the first element of A is a[0], and A is the address of the first element a[0], that is, A = &;; a[0]
Never think that A is the address of the first element a[0][0], but write it as A = &;; A [0][0], joke!
Remember: the first element of A is a[0], so you won't be confused when you learn multidimensional arrays and pointers in the future!
Type of p: int *
Type of q: int *[4]
Look again, what type is a[i]? Very simple, int [10]! One-dimensional array!
What about q[i] Int *?
Here comes the point: why does q[i] = a[i]? Don't you get it? !
(Disclaimer: The following is my personal original analysis method, original and ugly! )
In fact, if we look at the definitions of one-dimensional array and one-dimensional pointer, you will understand.
int A[ 10];
int * Q;
q = A; & gt& gt& gt understand? Bit arrays can be assigned to one-dimensional pointers. (only one dimension! )
But multi-bit arrays cannot be assigned to multi-bit pointers, remember!
Look at our question again: q[i] = a[i]?
Because (a[i]) is a one-dimensional array (parenthesis is because a[i] is a whole, remember: A is a so-called two-dimensional array! );
And the type of (q[i]) (also the whole) is int *, which is a pointer. So both can be allocated!
To sum up: find the type method and remove the name!
For array, remove int a[4][ 10], the type of a, and the name int [4] [10]; Type a[i], get int [10] by removing a[i]!
For the pointer, it is actually the same.
- Previous article:The bad guys are getting old. What is the first sentence?
- Next article:We can talk about guarding sweetheart.
- Related articles
- Factors Affecting English Listening Comprehension
Students' learning requirements for English listening are increasing day by day, and most students realize the inapplicability of "deaf-mute Eng
- The contents of cowherd and weaver girl's handwritten newspaper
- Fu Peiyufang Acne Repair Cream is suitable for face and friction. Why do you rub out the same thing as dead skin?
- Pay a little attention to the jingle for the anchor
- The Rain Boots of Wangzha is a thoughtful film for Tibetan children.
- Scorpio love running index: 70%?
- Do you have anything funny to say when you are in a bad mood?
- Is it illegal to watch porn on your mobile phone?
- Sad sentences: I would rather laugh and shed tears than cry and regret.
- I died like a joke.