How to see the actual size of a PTR?

How can I see the actual byte size of the pointer as output in the command prompt?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

using namespace std;


int main ()
{
    int x = 5;
    int* ptrX = &x;
    
    cout << ptrX << endl; // How can I print out, what is being 
                               //pointed at...see how much mem it takes up
    
    
    
    return 0;
}

///GOAL OUTPUT:

ptrX takes up 4 bytes
Last edited on
If you want the number of bytes used by ptrX use sizeof(ptrX).
If you want the number of bytes used by what it points to use sizeof(*ptrX).
Awesome thanks!
Topic archived. No new replies allowed.