Zhihu answered a fan question,Then the brother asked a series of questions:All right, help me out! Get Buddha to the west! Let me break it down for you!

1. int va;

This is an integer variable that takes 32 bites on a 32-bit CPU

2. int *va;

This is an integer pointer variable that holds the address of an integer variable,

3. int **va;

This is a second-level pointer to an integer that holds the address of a memory that contains the address of another integer variable

Such as:

int va=0x12345678;int *pva = &va;
 int **ppva = &pva;
Copy the code

4. int *va[3]

This is an array whose members are Pointers to ints

5. int (*va)[3]

This is a pointer to an array of ints

Note that the address type is int [3] and its value is 0x40004000,

Symbols with a value of 0x40004000 include:

a   &a[0]
Copy the code

But they don’t have the same type of va,

6. void *va(int)

This is a function

The function takes an int,

The return value is void *

7. Void (*va) (int)

This is a pointer to a function,

The function takes an int

The return value is void

For example,

void(* va) (int);void func(int num)
{
   printf("A bite of Linux %d\n",num);
}
va = func ;
/ / call
main()
{
   (*va)(6);
}
Copy the code

Note: The function name is also an address

8. int (*va[3])(int)

Combination mode:

  • Va is first combined with [3] to indicate that VA is an array

  • Va [3], so the array element is a pointer

  • Suppose (*va[3]) is X, and the outside is int (X) (int), so the pointer is to the function

  • The function takes an int and returns an int