+ 1

Write a code in C++, that declares an array of int type having the size of user's choice.

24th Dec 2017, 1:12 PM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
23 Respuestas
+ 3
https://code.sololearn.com/cbaJZnBBgxRA/?ref=app just keep learning cpp and try to ask google sometimes😉
24th Dec 2017, 1:26 PM
Botol
Botol - avatar
+ 3
@Timon cuz if he asks such questions he didnt know anything about vectors, dynamic arrays are more easy for understanding
24th Dec 2017, 1:50 PM
Botol
Botol - avatar
+ 2
Thanks this helped me a lot!
24th Dec 2017, 1:32 PM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
+ 2
@Curios i ve refreshed the code, look
24th Dec 2017, 1:46 PM
Botol
Botol - avatar
+ 2
@Timon im pretty sure that at the beginning of the studying he doesnt make such big projects to cause memory leaks, time will come and he will use vectors☺
24th Dec 2017, 1:55 PM
Botol
Botol - avatar
24th Dec 2017, 1:59 PM
Botol
Botol - avatar
+ 2
@Curios https://code.sololearn.com/cbaJZnBBgxRA/?ref=app just take an input of 'm' and fill the array with it
24th Dec 2017, 2:07 PM
Botol
Botol - avatar
+ 2
Ohh now I get that, here we are using n as a[n] [n] ;
24th Dec 2017, 2:07 PM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
+ 2
'n' rows, 'm' columns
24th Dec 2017, 2:14 PM
Botol
Botol - avatar
+ 2
If I give the values 3 and 4 to n and m respectively, does it mean the same as if I have declared an array a[3] [4] ;
24th Dec 2017, 2:21 PM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
+ 2
@Curios Im sorry) 'n' columns, 'm' rows, was busy, didnt look at variables
24th Dec 2017, 2:54 PM
Botol
Botol - avatar
+ 1
And how to do the same in 2D array?
24th Dec 2017, 1:43 PM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
+ 1
Yes, I'm beginner in the field of programming.
24th Dec 2017, 1:55 PM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
+ 1
@01ejka I want to declare an 2D array of user's choice
24th Dec 2017, 1:58 PM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
+ 1
No, that's not the case. I want m and n of user's choice declaring as array[m] [n] ;
24th Dec 2017, 2:03 PM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
+ 1
Wow, great thank you so much! @01ejka Here, m and n stands for what row or column?
24th Dec 2017, 2:10 PM
Çůřîöş ßąšäñț 🇮🇳
Çůřîöş ßąšäñț 🇮🇳 - avatar
0
Ok, it's possible. But why should you do this instead of using a vector? I mean, yes, there are some edge cases, but generally said, you want to use vectors for array-like data in the heap.
24th Dec 2017, 1:47 PM
Timon Paßlick
0
Ok, Curios Basant, please don't use this for arrays with a size greater than 10,000,000. Because if you're unlucky, you'll have to start your device again after that. Just in case you get the idea.
24th Dec 2017, 1:58 PM
Timon Paßlick
- 1
No, if he can't use vectors, he'll do memory leaks with dynamic arrays.
24th Dec 2017, 1:51 PM
Timon Paßlick
- 1
Just in case you're interested. https://code.sololearn.com/cLGivOK3G8Hi/?ref=app
24th Dec 2017, 2:05 PM
Timon Paßlick