0

Hello I'm trying to display the memory location(s) of an array of pointers. It works, but it prints the memory locations out as:

e.g.

(0x7fff672e19a0)

I know that is the memory location, but in other examples, I've seen it being displayed as

4041

Here is the function:

void display_pointer(int theSize)
{
    int counter = 0;
    for(int i=0; (i < theSize); i++)
    {
        
        char thePointer = myInt[i];
        
        char* ipPtr[theSize];
        
        ipPtr[i]= &thePointer;
        
        cout << *ipPtr[i];
        
        counter++;
    
        if(counter == 11)
        {
            cout << "(" << &ipPtr[i] << ")";
            counter = 0;
            
        }
    }   
}

Thanks =)

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by L7Sqr
0

A memory location has an address. Depending on your system the size of that address will vary. If you need to address 64 bits you will need more digits than addressing 32 bits. You may have been seen a hypothetical scenario where the numbers were used to in crease clarity and not necessarily to represent a true environment.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.