+ 1
size of vector and array not same why?
so here a example code #include <iostream> #include <vector> using namespace std; int main() { int myArray[3]{ 5, 10, 15 }; vector<int> myVector(begin(myArray), end(myArray)); for (int x : myVector) cout << x << " "; // 5 10 15 for(int i : myArray) cout<<i<<" "; cout<<"\n"<<sizeof(myVector); cout<<"\n"<<sizeof(myArray); } //output //5 10 15 5 10 15 //24 //12
2 Respuestas
+ 3
to determine size or length of vector, use vector.size();
hope this clears...
https://stackoverflow.com/questions/34024805/c-sizeof-vector-is-24
+ 1
thanks :)