+ 3
How to know size of array in c++?
if i don't know how many values is to put in array by user how can i make array suppose i make array a[5] but only 3 values is to put
3 Answers
+ 7
you can use dynamic arrays or vectors
int *m, n;
cin >> n;
m = new int [n];
...
...
+ 4
You can do what @01ejka said, or alternatively:
int a[] = {}; //Enter array
cout << sizeof(a)/sizeof(int);
Which will return the size of array.
- 1
You can also use a vector. The size of vectors is mutable.