Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between the int * i and int** i

Tags:

c++

c

pointers

What is the difference between int* i and int** i?

like image 618
M2star Avatar asked Sep 25 '10 14:09

M2star


People also ask

What is the difference between int * a and int * A?

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.

What is the difference between int and int * in C++?

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.

What is the difference between int * p and int * p?

They are the same. The first one considers p as a int * type, and the second one considers *p as an int .

What is int int * in C language?

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.


2 Answers

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)

like image 123
RJFalconer Avatar answered Oct 05 '22 18:10

RJFalconer


  • 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
  • ...
like image 38
Klaim Avatar answered Oct 05 '22 18:10

Klaim