sizeof function

I am extremely new to programing and I am trying to get this to work but for some reason I can't get it to run anything. I keep getting build errors....Can you help me?
You're much more likely to find an answer if you supply some code. It gives a great deal of context.

If it's just the use of size of, then you use it like this:

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>

using namespace std;

int main()
{
   int my_int = 50;
   cout << "My int has a value of: " << my_int << endl;
   cout << "My int has a size of " << sizeof(my_int) << " bytes" << endl;
   return 0;
}


Will output:
My int has a value of: 50
My int has a size of 4 bytes


The sizeof function returns the size of your object in bytes.
Last edited on
thanks. I just figured it out and found my mistake! Thanks alot for you help though!
Topic archived. No new replies allowed.