Equations of Structure Double Pointer
In this section, you are going to learn
What are the different ways of declarations ?
How to dervie equations ?
What are the Properties of Variable ?
What are the Properties of Expression ?
1. Equations of Double Pointer
In this section, you are going to learn
How to derive pointer equations for Double pointer ?
How to apply these equations to understand C statements ?
You can derive equations looking at C declarations !
There are many methods in C, using which a Double pointer can be declared. See below
1#include <stdio.h> 2 3struct ABC 4{ 5 int a; 6 int b; 7 int c; 8}; 9 10int main(void) 11{ 12 struct ABC x = {.a = 1, .b = 2, .c = 3}, *p = &x, **q = &p; 13 14 printf("x.a = %d\n", x.a); 15 printf("x.b = %d\n", x.b); 16 printf("x.c = %d\n", x.c); 17 18 printf("(**q).a = %d\n", (**q).a); 19 printf("(**q).b = %d\n", (**q).b); 20 printf("(**q).c = %d\n", (**q).c); 21 22 printf("(*q)[0].a = %d\n", (*q)[0].a); 23 printf("(*q)[0].b = %d\n", (*q)[0].b); 24 printf("(*q)[0].c = %d\n", (*q)[0].c); 25 26 printf("(*q)->a = %d\n", (*q)->a); 27 printf("(*q)->b = %d\n", (*q)->b); 28 printf("(*q)->c = %d\n", (*q)->c); 29 30 printf("q[0][0].a = %d\n", q[0][0].a); 31 printf("q[0][0].b = %d\n", q[0][0].b); 32 printf("q[0][0].c = %d\n", q[0][0].c); 33 34 return 0; 35}
Output is as below
x.a = 1 x.b = 2 x.c = 3 (**q).a = 1 (**q).b = 2 (**q).c = 3 (*q)[0].a = 1 (*q)[0].b = 2 (*q)[0].c = 3 (*q)->a = 1 (*q)->b = 2 (*q)->c = 3 q[0][0].a = 1 q[0][0].b = 2 q[0][0].c = 3
- In this example,
xis a structure
pis an single structure pointer
qis an double structure pointer
x,p,qare declared in one Single Line
x,p,qare assigned in one Single Line
xis assigned with value 10
pis assigned with address ofx
qis assigned with address ofp
1#include <stdio.h> 2 3struct ABC 4{ 5 int a; 6 int b; 7 int c; 8}; 9 10int main(void) 11{ 12 struct ABC x = {.a = 1, .b = 2, .c = 3}; 13 struct ABC *p = &x; 14 struct ABC **q = &p; 15 16 printf("x.a = %d\n", x.a); 17 printf("x.b = %d\n", x.b); 18 printf("x.c = %d\n", x.c); 19 20 printf("(**q).a = %d\n", (**q).a); 21 printf("(**q).b = %d\n", (**q).b); 22 printf("(**q).c = %d\n", (**q).c); 23 24 printf("(*q)[0].a = %d\n", (*q)[0].a); 25 printf("(*q)[0].b = %d\n", (*q)[0].b); 26 printf("(*q)[0].c = %d\n", (*q)[0].c); 27 28 printf("(*q)->a = %d\n", (*q)->a); 29 printf("(*q)->b = %d\n", (*q)->b); 30 printf("(*q)->c = %d\n", (*q)->c); 31 32 printf("q[0][0].a = %d\n", q[0][0].a); 33 printf("q[0][0].b = %d\n", q[0][0].b); 34 printf("q[0][0].c = %d\n", q[0][0].c); 35 36 return 0; 37}
Output is as below
x.a = 1 x.b = 2 x.c = 3 (**q).a = 1 (**q).b = 2 (**q).c = 3 (*q)[0].a = 1 (*q)[0].b = 2 (*q)[0].c = 3 (*q)->a = 1 (*q)->b = 2 (*q)->c = 3 q[0][0].a = 1 q[0][0].b = 2 q[0][0].c = 3
- In this example,
xis a structure
pis a single structure pointer
qis a double structure pointer
xis declared in a separate line
pis declared in a separate line
qis declared in a separate line
xis assigned in the same line of declaration
pis assigned in the same line of declaration
qis assigned in the same line of declaration
xis assigned with value 10
pis assigned with address ofx
qis assigned with address ofp
1#include <stdio.h> 2 3struct ABC 4{ 5 int a; 6 int b; 7 int c; 8}; 9 10int main(void) 11{ 12 struct ABC x; 13 struct ABC *p; 14 struct ABC **q; 15 16 x.a = 1; 17 x.b = 2; 18 x.c = 3; 19 20 p = &x; 21 22 q = &p; 23 24 printf("x.a = %d\n", x.a); 25 printf("x.b = %d\n", x.b); 26 printf("x.c = %d\n", x.c); 27 28 printf("(**q).a = %d\n", (**q).a); 29 printf("(**q).b = %d\n", (**q).b); 30 printf("(**q).c = %d\n", (**q).c); 31 32 printf("(*q)[0].a = %d\n", (*q)[0].a); 33 printf("(*q)[0].b = %d\n", (*q)[0].b); 34 printf("(*q)[0].c = %d\n", (*q)[0].c); 35 36 printf("(*q)->a = %d\n", (*q)->a); 37 printf("(*q)->b = %d\n", (*q)->b); 38 printf("(*q)->c = %d\n", (*q)->c); 39 40 printf("q[0][0].a = %d\n", q[0][0].a); 41 printf("q[0][0].b = %d\n", q[0][0].b); 42 printf("q[0][0].c = %d\n", q[0][0].c); 43 44 return 0; 45}
Output is as below
x.a = 1 x.b = 2 x.c = 3 (**q).a = 1 (**q).b = 2 (**q).c = 3 (*q)[0].a = 1 (*q)[0].b = 2 (*q)[0].c = 3 (*q)->a = 1 (*q)->b = 2 (*q)->c = 3 q[0][0].a = 1 q[0][0].b = 2 q[0][0].c = 3
- In this example,
xis a structure
pis a single structure pointer
qis a double structure pointer
xis declared in a separate line
pis declared in a separate line
qis declared in a separate line
xis assigned and is not part of declaration
pis assigned and is not part of declaration
qis assigned and is not part of declaration
xis assigned with value 10
pis assigned with address ofx
qis assigned with address ofp
Decl #
Declaration
Description
Decl 1
struct ABC x, *p = &x, **q = &p;
Structure x, Single Pointer p, Double Pointer q are declared and assigned in same line
Decl 2
struct ABC x;
struct ABC *p = &x;
struct ABC **q = &p;
Structure x, Single Pointer p, Double Pointer q are declared and assigned in separate lines
Decl 3
struct ABC x;
struct ABC *p;
- struct ABC **q;
x.a = 1;
x.b = 2;
x.c = 3;
p = &x;
q = &p;
Structure x, Single Pointer p, Double Pointer q are declared in one line and assigned in another line
Whenever we see any of the above methods of declarations, we need to rewrite them such that, declarations and assignments are not in same line. Similar to Declaration 3
Equation 1 : Obtained from
Step 2p = &x;
Equation 2 : Move
&to the left of First Equation. It turns in to**p = x;
Equation 3 : * and [0] can be used interchangeably. Hence
*pandp[0]are one and the same !p[0] = x;
Equation 4 : From Equation 2, Equation 3, we can derive that
x,*p,p[0]all are same !*p = p[0] = x;
Equation 5 : Obtained from
Step 2q = &p;
Equation 6 : Move & to the left of First Equation. It turns in to *
*q = p;
Equation 7 : * and [0] can be used interchangeably. Hence *q and q[0] are one and the same !
q[0] = p;
Equation 8 : From Equation 6, Equation 7, we can derive that
p,*q,q[0]all are same !*q = q[0] = p;
Equation 9 : From Equation 1, we know
p = &x. Hence Replacepwith&xin Equation 8*q = q[0] = &x;
Equation 10 : Move & to the left of Equation 9. It turns in to *
**q = *q[0] = x;
Equation 11 : * and [0] can be used interchangeably
q[0][0] = x;
Equation #
Equation
Description
Equation 1
p = &x
Base condition
Equation 2
*p = x
From Equation 1, Move & from RHS to LHS to get * on LHS
Equation 3
p[0] = x
* and [0] can be used interchangeably. Hence *p and p[0] are synonyms
Equation 4
*p = p[0] = x
From Equation 2, 3 we can conclude *p, p[0], x are synonyms
Equation #
Equation
Description
Equation 5
q = &p
Base condition
Equation 6
*q = p
From Equation 5, Move & from RHS to LHS to get * on LHS
Equation 7
q[0] = p
* and [0] can be used interchangeably. Hence *q and q[0] are synonyms
Equation 8
*q = q[0] = p
From Equation 6, Equation 7, we can derive that p, *q, q[0] all are same !
Equation 9
*q = q[0] = &x
From Equation 1, we know p = &x. Hence Replace p with &x in Equation 8
Equation 10
**q = *q[0] = x
From Equation 9, Move & from RHS to LHS to get * on LHS
Equation 11
q[0][0] = x
* and [0] can be used interchangeably
(*p).a = 10; (*p).b = 20; (*p).c = 30; printf("(*p).a = %d\n", (*p).a); printf("(*p).b = %d\n", (*p).b); printf("(*p).c = %d\n", (*p).c);Output is as below
(*p).a = 10 (*p).b = 20 (*p).c = 30p[0].a = 10; p[0].b = 20; p[0].c = 30; printf("p[0].a = %d\n", p[0].a); printf("p[0].b = %d\n", p[0].b); printf("p[0].c = %d\n", p[0].c);Output is as below
p[0].a = 10 p[0].b = 20 p[0].c = 30x.a = 100; printf("x.a = %d\n", x.a); printf("(*p).a = %d\n", (*p).a); printf("p[0].a = %d\n", p[0].a); printf("p->a = %d\n", p->a);Output is as below
x.a = 100 (*p).a = 100 p[0].a = 100 p->a = 100p->a = 10; p->b = 20; p->c = 30; printf("p->a = %d\n", p->a); printf("p->b = %d\n", p->b); printf("p->c = %d\n", p->c);Output is as below
p->a = 10 p->b = 20 p->c = 30(**q).a = 100; printf("x.a = %d, (**q).a = %d\n", x.a, (**q).a);
- Output :
x.a= 100,(**q).a= 100(*q)[0].a = 100; printf("x.a = %d, (*q)[0].a = %d\n", x.a, (*q)[0].a);
- Output :
x.a= 100,(*q)[0].a= 100q[0][0].a = 100; printf("x.a = %d, q[0][0].a = %d\n", x.a, q[0][0].a);
- Output :
x.a= 100,q[0][0].a= 100struct ABC x, y, *p, **q; x.a = 100; p = &x; q = &p; printf("(*p).a = %d, p[0].a = %d, (**q).a = %d\n", (*p).a, p[0].a, (**q).a); y.a = 200; // *q, p are synonyms. // Means *q = &y also means p = &y *q = &y; printf("(*p).a = %d, p[0].a = %d, (**q).a = %d\n", (*p).a, p[0].a, (**q).a);
- Output :
(*p).a= 100,p[0].a= 100,(**q).a= 100
(*p).a= 200,p[0].a= 200,(**q).a= 200struct ABC x, y, *p, **q; x.a = 100; p = &x; q = &p; printf("(*p).a = %d, p[0].a = %d, (**q).a = %d\n", (*p).a, p[0].a, (**q).a); y.a = 200; // q[0], p are synonyms. // Means q[0] = &y also means p = &y q[0] = &y; printf("(*p).a = %d, p[0].a = %d, (**q).a = %d\n", (*p).a, p[0].a, (**q).a);
- Output :
(*p).a= 100,p[0].a= 100,(**q).a= 100
(*p).a= 200,p[0].a= 200,(**q).a= 2001#include <stdio.h> 2 3struct ABC 4{ 5 int a; 6 int b; 7 int c; 8}; 9 10int main(void) 11{ 12 struct ABC x; 13 14 struct ABC *p; 15 16 struct ABC **q; 17 18 x.a = 10; 19 20 p = &x; 21 22 q = &p; 23 24 printf("x.a = %d, (*p).a = %d, p[0].a = %d, (**q).a = %d\n", x.a, (*p).a, p[0].a, (**q).a); 25 26 x.a = 20; 27 28 printf("x.a = %d, (*p).a = %d, p[0].a = %d, (**q).a = %d\n", x.a, (*p).a, p[0].a, (**q).a); 29 30 (*p).a = 30; 31 32 printf("x.a = %d, (*p).a = %d, p[0].a = %d, (**q).a = %d\n", x.a, (*p).a, p[0].a, (**q).a); 33 34 p[0].a = 40; 35 36 printf("x.a = %d, (*p).a = %d, p[0].a = %d, (**q).a = %d\n", x.a, (*p).a, p[0].a, (**q).a); 37 38 (**q).a = 50; 39 printf("x.a = %d, (*p).a = %d, p[0].a = %d, (**q).a = %d\n", x.a, (*p).a, p[0].a, (**q).a); 40 41 return 0; 42}
Output is as below
x.a = 10, (*p).a = 10, p[0].a = 10, (**q).a = 10 x.a = 20, (*p).a = 20, p[0].a = 20, (**q).a = 20 x.a = 30, (*p).a = 30, p[0].a = 30, (**q).a = 30 x.a = 40, (*p).a = 40, p[0].a = 40, (**q).a = 40 x.a = 50, (*p).a = 50, p[0].a = 50, (**q).a = 50
2. Properties of a variable
In this section, you are going to learn
Properties of a variable
Type of a variable ?
Size of a variable ?
Scope, Lifetime and Memory of a variable ?
1struct ABC x; 2 3struct ABC *p; 4 5struct ABC **q; 6 7p = &x; 8 9q = &p;
In above code snippet, there are three variables
x,p,q
Variable
Type
Description
type_of(x)
struct ABC
See Line 1
type_of(p)
struct ABC *
See Line 3
type_of(q)
struct ABC **
See Line 5
Adress of variable must be stored in next level pointer type always
1struct ABC x; 2 3struct ABC *p; 4 5struct ABC **q; 6 7p = &x; 8 9q = &p;
In above code snippet, there are two variables
x,p
Variable
Type
Description
type_of(&x)
struct ABC *
type_of(x)isstruct ABCHence,
type_of(&x)isstruct ABC *type_of(&p)
struct ABC **
type_of(p)isstruct ABC *Hence,
type_of(&p)isstruct ABC **type_of(&q)
struct ABC ***
type_of(q)isstruct ABC **Hence,
type_of(&q)isstruct ABC ***
Sizeof(type)
Size
sizeof(char)
1 Byte
sizeof(int)
4 Bytes
sizeof(float)
4 Bytes
sizeof(double)
8 Bytes
sizeof(pointer types)is always 8 Bytes, where pointer is single, double, triple etc.,:
Sizeof(type *)
Size
sizeof(char *)
8 Bytes
sizeof(int *)
8 Bytes
sizeof(float *)
8 Bytes
sizeof(double *)
8 Bytes
sizeof(struct xyz *)
8 Bytes
sizeof(union xyz *)
8 Bytes
Sizeof(type **)
Size
sizeof(char **)
8 Bytes
sizeof(int **)
8 Bytes
sizeof(float **)
8 Bytes
sizeof(double **)
8 Bytes
sizeof(struct xyz **)
8 Bytes
sizeof(union xyz **)
8 Bytes
etc.,
sizeof(&variable)is always 8 Bytes, wheretype_of(variable)can be anything
Sizeof(&variable)
Size
Declaration
sizeof(&x)
8 Bytes
char x;sizeof(&x)
8 Bytes
int x;sizeof(&x)
8 Bytes
float x;sizeof(&x)
8 Bytes
double x;sizeof(&x)
8 Bytes
struct xyz x;sizeof(&x)
8 Bytes
union xyz x;
Sizeof(&variable)
Size
Declaration
sizeof(&x)
8 Bytes
char *x;sizeof(&x)
8 Bytes
int *x;sizeof(&x)
8 Bytes
float *x;sizeof(&x)
8 Bytes
double *x;sizeof(&x)
8 Bytes
struct xyz *x;sizeof(&x)
8 Bytes
union xyz *x;
Sizeof(&variable)
Size
Declaration
sizeof(&x)
8 Bytes
char **x;sizeof(&x)
8 Bytes
int **x;sizeof(&x)
8 Bytes
float **x;sizeof(&x)
8 Bytes
double **x;sizeof(&x)
8 Bytes
struct xyz **x;sizeof(&x)
8 Bytes
union xyz **x;
sizeof(variable)equalssizeof(typeof(variable))1struct ABC x; 2 3struct ABC *p; 4 5struct ABC **q; 6 7p = &x; 8 9q = &p;
In above code snippet, there are three variables
x,p,q
Sizeof(Variable)
Size
Description
sizeof(x)
12 Bytes
- How ?
Step 1 :
sizeof(x)equalssizeof(typeof(x))Step 2 :
type_of(x)isstruct ABCStep 3 :
sizeof(struct ABC)is12 BytesHence,
sizeof(x)is12 Bytessizeof(p)
8 Bytes
- How ?
Step 1 :
sizeof(p)equalssizeof(typeof(p))Step 2 :
type_of(p)isstruct ABC *Step 3 :
sizeof(struct ABC *)is8 BytesHence,
sizeof(p)is8 Bytessizeof(q)
8 Bytes
- How ?
Step 1 :
sizeof(q)equalssizeof(typeof(q))Step 2 :
type_of(q)isstruct ABC **Step 3 :
sizeof(struct ABC **)is8 BytesHence,
sizeof(q)is8 Bytes
Global Scope and Lifetime.
Local Scope and Lifetime
3. Properties of Expressions
In this section, you are going to learn
Properties of Expressions
What is an Expression ?
Table of Expressions
Table of Size (for Expressions)
Table of Type (for Expressions)
Table of Address/Value (for Expression)
Table of Function Prototype (for Expression)
1struct ABC x;
2
3struct ABC *p;
4
5struct ABC **q;
6
7p = &x;
8
9q = &p;
10
11(*p).a = 100; // or p->a = 100;
12
13(**q).a = 100; // or (*q)->a = 100;
Expression
Description
x
xis a structure&x
&xis address of a structure
&xis a single pointerp
pis a pointer to a structure
pis a single pointer&p
&pis address of a pointer
&pis a double pointer*p
*pis a structure, because*p = x. See Equation 2p[0]
p[0]is a structure, becausep[0] = x. See Equation 3q
qis a double pointer and holds the address of a single pointer&q
&qis address of a double pointer
&qis a triple pointer*q
*qholds the address of structure x. See Equation 9
*qis a single pointer.*q = p. See Equation 8q[0]
q[0]holds the address of structure x. See Equation 9
q[0]is a single pointer.*q = p. See Equation 8**q
**qis a structure. See Equation 10*q[0]
*q[0]is a structure. See Equation 10q[0][0]
q[0][0]is a structure. See Equation 11
Expression
Size
Description
sizeof(x)
12 Bytes
sizeof(&x)
8 Bytes
sizeof(p)
8 Bytes
sizeof(&p)
8 Bytes
sizeof(*p)
12 Bytes
Step 1 :
sizeof(*p)equalssizeof(x)See Equation 2Step 2 :
sizeof(x)equalssizeof(type_of(x))See Property 2.4Step 3 :
sizeof(type_of(x))equalssizeof(struct ABC)See Property 1.1Step 4 :
sizeof(struct ABC)equals 12 Bytessizeof(p[0])
12 Bytes
Step 1 :
sizeof(p[0])equalssizeof(x)``= xSee Equation 3Step 2 :
sizeof(x)equalssizeof(type_of(x))See Property 2.4Step 3 :
sizeof(type_of(x))equalssizeof(struct ABC)See Property 1.1Step 4 :
sizeof(struct ABC)equals 12 Bytessizeof(q)
8 Bytes
sizeof(&q)
8 Bytes
sizeof(*q)
8 Bytes
Step 1 :
sizeof(*q)equalssizeof(p). See Equation 8Step 2 :
sizeof(p), equalssizeof(type_of(p))See Property 2.4Step 3 :
sizeof(type_of(p))equalssizeof(struct ABC *)See Property 1.1Step 4 :
sizeof(struct ABC *)equals 8 Bytessizeof(q[0])
8 Bytes
Step 1 :
sizeof(q[0])equalssizeof(p)See Equation 8Step 2 :
sizeof(p)equalssizeof(type_of(p))See Property 2.4Step 3 :
sizeof(type_of(p))equalssizeof(struct ABC *)See Property 1.1Step 4 :
sizeof(struct ABC *)* equals 8 Bytessizeof(**q)
12 Bytes
Step 1 :
sizeof(**q)equalssizeof(x)See Equation 10Step 2 :
sizeof(x)equalssizeof(type_of(x))See Property 2.4Step 3 :
sizeof(type_of(x))equalssizeof(struct ABC)See Property 1.1Step 4 :
sizeof(struct ABC)equals 12 Bytessizeof(*q[0])
12 Bytes
Step 1 :
sizeof(*q[0])equalssizeof(x)See Equation 10Step 2 :
sizeof(x)equalssizeof(type_of(x))See Property 2.4Step 3 :
sizeof(type_of(x))equalssizeof(struct ABC)See Property 1.1Step 4 :
sizeof(struct ABC)equals 12 Bytessizeof(q[0][0])
12 Bytes
Step 1 :
sizeof(q[0][0])equalssizeof(x)See Equation 11Step 2 :
sizeof(x)equalssizeof(type_of(x))See Property 2.4Step 3 :
sizeof(type_of(x))equalssizeof(struct ABC)See Property 1.1Step 4 :
sizeof(struct ABC)equals 12 Bytes
Expression
Type
Description
type_of(x)
struct ABC
type_of(&x)
struct ABC *
type_of(p)
struct ABC *
type_of(&p)
struct ABC **
type_of(*p)
struct ABC
Step 1 :
type_of(*p)equalstype_of(x), because*p = x. See Equation 2Step 2 :
type_of(x)equalsstruct ABCtype_of(p[0])
struct ABC
Step 1 :
type_of(p[0])equalstype_of(x), becausep[0] = x. See Equation 3Step 2 :
type_of(x)equalsstruct ABCtype_of(q)
struct ABC **
type_of(&q)
struct ABC ***
type_of(*q)
struct ABC *
Step 1 :
type_of(*q)equalstype_of(p). See Equation 8Step 2 :
type_of(p), equalsstruct ABC *See Property 1.1type_of(q[0])
struct ABC *
Step 1 :
type_of(q[0])equalstype_of(p)See Equation 8Step 2 :
type_of(p)equalsstruct ABC *See Property 1.1type_of(**q)
struct ABC
Step 1 :
type_of(**q)equalstype_of(x)See Equation 10Step 2 :
type_of(x)equalsstruct ABCSee Property 1.1type_of(*q[0])
struct ABC
Step 1 :
type_of(*q[0])equalstype_of(x)See Equation 10Step 2 :
type_of(x)equalsstruct ABCSee Property 1.1type_of(q[0][0])
struct ABC
Step 1 :
type_of(q[0][0])equalstype_of(x)See Equation 11Step 2 :
type_of(x)equalsstruct ABCSee Property 1.1
Expression
Address/Value
Description
x
Value
Step 1 :
xis a structureStep 2 : Hence
xis a value&x
Address
& operator indicates address
p
Address
Step 1 :
p = &xSee Equation 1Step 2 : & operator indicates address
&p
Address
& operator indicates address
*p
Value
Step 1 :
*pis a structure.*p = xSee Equation 2Step 2 : Hence
*pis a valuep[0]
Value
Step 1 :
p[0]is a structure.p[0] = xSee Equation 3Step 2 : Hence
p[0]is a valueq
Address
Step 1 :
q = &pSee Equation 5Step 2 : & operator indicates address
&q
Address
& operator indicates address
*q
Address
Step 1 :
*q = pSee Equation 6Step 2 :
p = &xStep 3 : & operator indicates address
q[0]
Address
Step 1 :
q[0] = pSee Equation 7Step 2 :
p = &xStep 3 : & operator indicates address
**q
Value
Step 1 :
**q = xSee Equation 10Step 2 :
xis a structureStep 3 :
**qis a Value*q[0]
Value
Step 1 :
*q[0] = xSee Equation 10Step 2 :
xis a structureStep 3 :
*q[0]is a Valueq[0][0]
Value
Step 1 :
q[0][0] = xSee Equation 11Step 2 :
xis a structureStep 3 :
q[0][0]is a Value
If
fun(v)is function call then,fun(type_of(v))is the prototype
Function call
Function Prototype
Description
fun(x)
void fun(struct ABC x);
fun(&x)
void fun(struct ABC *p);
fun(p)
void fun(struct ABC *p);
fun(&p)
void fun(struct ABC **p);
fun(*p)
void fun(struct ABC x);
Step 1 :
fun(*p)equalsfun(x)See Equation 2Step 2 :
fun(x)equalsfun(type_of(x))Step 3 :
fun(type_of(x))equalsfun(struct ABC)fun(p[0])
void fun(struct ABC x);
Step 1 :
fun(p[0])equalsfun(x)See Equation 2Step 2 :
fun(x)equalsfun(type_of(x))Step 3 :
fun(type_of(x))equalsfun(struct ABC)fun(q)
void fun(struct ABC **q);
fun(&q)
void fun(struct ABC ***q);
fun(*q)
void fun(struct ABC *q);
Step 1 :
fun(*q)equalsfun(p)Step 2 :
fun(p)equalsfun(type_of(p))Step 3 :
fun(type_of(p))equalsfun(struct ABC *)fun(q[0])
void fun(struct ABC *q);
Step 1 :
fun(q[0])equalsfun(p)Step 2 :
fun(p)equalsfun(type_of(p))Step 3 :
fun(type_of(p))equalsfun(struct ABC *)fun(**q)
void fun(struct ABC x);
Step 1 :
fun(**q)equalsfun(x)See Equation 10Step 2 :
fun(x)equalsfun(type_of(x))Step 3 :
fun(type_of(x))equalsfun(struct ABC)fun(*q[0])
void fun(struct ABC x);
Step 1 :
fun(*q[0])equalsfun(x)See Equation 10Step 2 :
fun(x)equalsfun(type_of(x))Step 3 :
fun(type_of(x))equalsfun(struct ABC)fun(q[0][0])
void fun(struct ABC x);
Step 1 :
fun(q[0][0])equalsfun(x)See Equation 11Step 2 :
fun(x)equalsfun(type_of(x))Step 3 :
fun(type_of(x))equalsfun(struct ABC)
4. Summary
# |
? |
Size in Bytes |
Type |
Address or Value |
Function call |
Function Prototype |
|---|---|---|---|---|---|---|
x |
Structure |
12 |
struct ABC |
Value |
fun(x) |
void fun(struct ABC x); |
&x |
Single Pointer |
8 |
struct ABC * |
Address |
fun(&x) |
void fun(struct ABC *p); |
p |
Single Pointer |
8 |
struct ABC * |
Address |
fun(p) |
void fun(struct ABC *p); |
&p |
Double Pointer |
8 |
struct ABC ** |
Address |
fun(&p) |
void fun(struct ABC **q); |
*p |
Structure |
12 |
struct ABC |
Value |
fun(*p) |
void fun(struct ABC x); |
p[0] |
Structure |
12 |
struct ABC |
Value |
fun(p[0]) |
void fun(struct ABC x); |
q |
Double Pointer |
8 |
struct ABC ** |
Address |
fun(q) |
void fun(struct ABC **q); |
&q |
Triple Pointer |
8 |
struct ABC *** |
Address |
fun(&q) |
void fun(struct ABC ***r); |
*q |
Single Pointer |
8 |
struct ABC * |
Address |
fun(*q) |
void fun(struct ABC *p); |
q[0] |
Single Pointer |
8 |
struct ABC * |
Address |
fun(q[0]) |
void fun(struct ABC *p); |
**q |
Structure |
12 |
struct ABC |
Value |
fun(**q) |
void fun(struct ABC x); |
*q[0] |
Structure |
12 |
struct ABC |
Value |
fun(*q[0]) |
void fun(struct ABC x); |
q[0][0] |
Structure |
12 |
struct ABC |
Value |
fun(q[0][0]) |
void fun(struct ABC x); |
Current Module
Next Module
Other Modules