Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * sizeof.cpp
- *
- * Created on: Jun 27, 2012
- * Author: Derek
- *
- * Some examples of using the sizeof operator
- */
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "int: " << sizeof(int) << " bytes" << endl;
- cout << "boolean: " << sizeof(bool) << " bytes" << endl;
- int a[5];
- cout << "The size of a five element int array is " << sizeof(a) << " bytes." << endl;
- cout << "The number of elements in the array 'a' is " << sizeof(a) / sizeof(int) << "." << endl;
- cout << "The size of an int pointer is " << sizeof(int*) << " bytes." << endl;
- cout << "The size of an double pointer is " << sizeof(double*) << " bytes." << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment