Debug Qt vs memory edit

  • Hi all,
    I have a question about debugging on Qt - Ubuntu 64bits. Currently, I have a code as follows:
    int a = 257;
    char* p = (char*)&a;
    However, my issue is printf pointer's address and address of object is different.
    Address of pointer - printf: prinntf("%p", p) - Result: 0x7ffef7ccd694
    Address of pointer - open memory edit: 7ffef7ccd698
    Who can explain this issue help me? Thanks for advanced.

  • Hi, the 1st address is what the pointer points to (the value of the pointer) and the 2nd address is the address to the pointer itself.

  • Moderators

    First of all there's no pointers in your example. %p is for printing pointers and p is not a pointer.
    If you want to print the value of p, which is the truncated address of a, you would use printf("%d", p).
    If you want to print the address of p you would use printf("%p", &p).

  • Thank all,
    I also wanna ask more a question. If I wanna watch value at address what the pointer point to - value of pointer - in memory edit
    So what to it will be show how on Qt instead of printf address and then pass those address to memory edit ? Because when open memory edit, it is address of pointer - not address pointer points to.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.