New course! Every coder should learn Generative AI!
Try a free lesson+ 6
Function sizeof() eturns size in bytes of the variable of some type.
E.g.
#include <iostream>
using namespace std;
int main()
{
cout << sizeof(char) << endl;
cout << sizeof(int) << endl;
cout << sizeof(string) << endl;
cout << sizeof(bool) << endl;
return 0;
}
// outputs
// 1
// 4
// 4
// 1
Further reference:
http://en.cppreference.com/w/cpp/language/sizeof