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 =)

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.