[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppSizeof
The code below shows the memory consumed by an array and vector.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppSizeof
(C++) sizeof
Keyword to determine the memory used by a certain data type.The code below shows the memory consumed by an array and vector.
int main() { const int smallSize = 10; const int bigSize = 10000; int smallArray[smallSize]; int bigArray[bigSize]; std::vector<int> smallVector(smallSize); std::vector<int> bigVector(bigSize); std::cout << "Int: " << sizeof(int) << std::endl; std::cout << "Small array: " << sizeof(smallArray) << std::endl; std::cout << "Big array: " << sizeof(bigArray) << std::endl; std::cout << "Small vector: " << sizeof(smallVector) << std::endl; std::cout << "Big vector: " << sizeof(bigVector) << std::endl; }
- include <iostream>
- include <vector>
Code links
- ::, scope operator
- <<, stream out operator
- #include
- char
- const
- cout
- endl
- #include
- int
- iostream
- main
- return
- scope operator, ::
- std
- stream out operator, <<
- vector
'sizeof' links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
