+ 13
Can we create array whose size is unknown???
How do we take input of array whose size is not known?
6 Respuestas
+ 6
You can't.
That's why arrays are known as static data structures, that means you have to assign the size at the compile time only. It is a general practice to take the array size large enough so that it can fullfill expected requirements.
Or
If you know the concept of dynamic memory allocation then there is a thing known as dynamic array. More famously known as *vectors*(defined in stl) in C++.
+ 6
Thnks
+ 5
for that you can Use Vectors
+ 2
Use a vector (See http://www.cplusplus.com/reference/vector/vector/) or list (http://www.cplusplus.com/reference/list/list/ ). Vectors are better for indexing, and lists are better for inserting/removing.
0
Hi! Previously I created a sample program that addresses this case.
https://www.sololearn.com/Discuss/2372341/?ref=app