+ 2

int **p = new int*[100]

What does it means please clarify?

22nd Dec 2019, 2:31 PM
Piyush Srivastava
Piyush Srivastava - avatar
13 Antworten
+ 2
these are multidimensional arrays i.e. an array of arrays it can be fully qualified as int**p= new int[100][100]
24th Dec 2019, 6:21 AM
Ehsaas Thakur
Ehsaas Thakur - avatar
+ 3
p is an array of 100 pointers. `new int*[ number ]` creates an array with <number> pointers. `int **p` can be rewritten as `int* *p`, which can be rewritten as `int* p[ <size of array> ]` https://www.quora.com/What-is-int-x-new-int-n/answer/Slava-Osipov?ch=10&share=f35ae599&srid=iwqHc ---- Edit: Thanks Ritwik for correcting me
22nd Dec 2019, 3:25 PM
Edwin Pratt
Edwin Pratt - avatar
+ 3
Ritwik, Thanks for telling me 😇 may you please explain what I got wrong?
22nd Dec 2019, 3:46 PM
Edwin Pratt
Edwin Pratt - avatar
+ 3
p is an integer pointer to an array of 100 integer pointer values but the new function is used to allocate memory dynamically during run time
22nd Dec 2019, 3:46 PM
Ritwik
+ 2
Actually in offline compilers unlike sololearn we first have to compile our code then run it
22nd Dec 2019, 3:48 PM
Ritwik
+ 2
Ritwik, Oh,, I see my mistake 🤦🏻‍♂️ thanks for correcting me
22nd Dec 2019, 3:48 PM
Edwin Pratt
Edwin Pratt - avatar
+ 2
Compiling turns into binary language
22nd Dec 2019, 3:48 PM
Ritwik
+ 2
And run executes it
22nd Dec 2019, 3:49 PM
Ritwik
+ 2
So normal variables are declared during compile time
22nd Dec 2019, 3:49 PM
Ritwik
+ 2
But adding (new) stores them during run time
22nd Dec 2019, 3:50 PM
Ritwik
+ 1
Edwin you are a little wrong
22nd Dec 2019, 3:44 PM
Ritwik
+ 1
Which can help to take the number of values from the user
22nd Dec 2019, 3:52 PM
Ritwik
0
My pleasure Edwin
22nd Dec 2019, 3:57 PM
Ritwik