1 2 3 4 5 6 7 8
#include <stdio.h> int main(){ char* str1="Hello"; printf("\nstr1: %s, address: %p, sizeof(str1): %u", str1, str1, sizeof(str1)); str1 = "world"; printf("\nstr1: %s, address: %p, sizeof(str1): %u", str1, str1, sizeof(str1)); return 1; }
1 2 3
str1: Hello, address: 0x80485e8, sizeof(str1): 4 str1: world, address: 0x8048619, sizeof(str1): 4