linux print address offset of different data types

program:

#include "stdio.h"

void main(void)
{
    printf("void offset:%x(%d)\n", (((void *)NULL)+1),(((void *)NULL)+1));
    printf("char offset:%x(%d)\n", (((char *)NULL)+1),(((char *)NULL)+1));
    printf("short offset:%x(%d)\n", (((short *)NULL)+1),(((short *)NULL)+1));
    printf("int offset:%x(%d)\n", (((int *)NULL)+1),(((int *)NULL)+1));
    printf("long offset:%x(%d)\n", (((long *)NULL)+1),(((long *)NULL)+1));
    printf("long long offset:%x(%d)\n", (((long long*)NULL)+1),(((long long*)NULL)+1));
}

operation result:

void offset:1(1)
char offset:1(1)
short offset:2(2)
int offset:4(4)
long offset:8(8)
long long offset:8(8)

 

Guess you like

Origin blog.csdn.net/eidolon_foot/article/details/112298372