What is the difference between int* i
and int** i
?
There is no such difference in between these two types of array declaration. It's just what you prefer to use, both are integer type arrays. There is no difference in functionality between both styles of declaration.
int means a variable whose datatype is integer. sizeof(int) returns the number of bytes used to store an integer. int* means a pointer to a variable whose datatype is integer. sizeof(int*) returns the number of bytes used to store a pointer.
They are the same. The first one considers p as a int * type, and the second one considers *p as an int .
int. Integers are whole numbers that can have both zero, positive and negative values but no decimal values. For example, 0 , -5 , 10. We can use int for declaring an integer variable.
Pointer to an integer value
int* i
Pointer to a pointer to an integer value
int** i
(Ie, in the second case you will require two dereferrences to access the integer's value)
int* i
: i
is a pointer to a object of type int
int** i
: i
is a pointer to a pointer to a object of type int
int*** i
: i
is a pointer to a pointer to a pointer to object of type int
int**** i
: i
is a pointer to a pointer to a pointer to a pointer to object of type int
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With