Getting the size in bytes of a vector [duplicate]
This question already has an answer here: sizeof() std::vector (C++) 2 answers Sorry for this maybe simple and stupid question but I couldn't find it anywhere. I just don't know how to get the size in bytes of a std::vector. std::vector<int>MyVector; /* This will print 24 on my system*/ std::cout << "Size of my vector:\t" << sizeof(MyVector) << std::endl; for(int i = 0; i < 1000; i++) MyVector.push_back(i); /* This will still print 24...*/ std::cout << "Size of my vector:\t" << sizeof(MyVector) << std::endl; So how do I get the size of a vector?! Maybe by multiplying 24 (vector size) by the