b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <unistd.h> |
| 4 | |
| 5 | int pub_int_d = 4; |
| 6 | char *str = "abc"; |
| 7 | int bss_1; |
| 8 | |
| 9 | //int bss_1; |
| 10 | //static int static_bss_2; |
| 11 | |
| 12 | void test(int c) |
| 13 | { |
| 14 | // int d = 10; |
| 15 | //printf("函数参数:test_c = %p, 局部变量:d = %p\n", &c, &d); |
| 16 | } |
| 17 | |
| 18 | int main(int argc, char *argv[]) |
| 19 | { |
| 20 | printf("[栈]函数参数:argc = %p, argv = %p\n", &argc, argv); |
| 21 | |
| 22 | int int_a; |
| 23 | static int static_int_b; |
| 24 | char *temp_malloc = (char*)malloc(10); |
| 25 | const char temp[10]; |
| 26 | |
| 27 | printf("[栈]局部变量:int_a[%d] = %p, [BSS]局部静态变量:static_int_b[%d] = %p\n", int_a, &int_a, static_int_b, &static_int_b); |
| 28 | printf("[DATA]全局变量:pub_int_d[%d] = %p\n", pub_int_d, &pub_int_d); |
| 29 | printf("常量:str = %p, 堆空间:temp_malloc = %p\n", str, temp_malloc); |
| 30 | printf("函数:test_func = %p\n", test); |
| 31 | printf("const_str = %p, &(temp[3]) = %p\n", temp, &(temp[3])); |
| 32 | printf("BSS : %d, %p\n", bss_1, &bss_1); |
| 33 | |
| 34 | test(5); |
| 35 | |
| 36 | while(1) { |
| 37 | sleep(24 * 60 * 60); |
| 38 | } |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | |