0

How to input int values from user n store it in array dynamically in c++?

22nd Aug 2018, 7:57 AM
abhishek khanna
abhishek khanna - avatar
5 Réponses
+ 8
abhishek khanna you cannot do that with arrays even not with the dynamic arrays. You can do that either with Vector or Linked-List
22nd Aug 2018, 9:10 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 1
Do you mean something like this? cin >> n; int* arr = new int [n]; for (int i = 0; i<n; i++) cin >> arr[i];
22nd Aug 2018, 8:03 AM
Kapi
+ 1
I tried your code but it didn't help. I am looking for a code which take input from user and store it in an array, without setting the limit of array
22nd Aug 2018, 8:24 AM
abhishek khanna
abhishek khanna - avatar
+ 1
I'll think about it but maybe you want to use list? https://www.sololearn.com/learn/645/?ref=app
22nd Aug 2018, 8:30 AM
Kapi
0
Thank you everyone
22nd Aug 2018, 10:18 AM
abhishek khanna
abhishek khanna - avatar