代码:
#include <stdio.h> #include <stdlib.h> // 字符串常量属于静态存储(static storage)类 // 静态存储类是指如果一个函数中使用字符串常量,即使多次调用这个函数,该字符串在程序的整个运行过程中只存储一份 int main(void) { const char * s1 = "Hello World"; const char * s2 = NULL; printf("value = %s, address = %p\n", s1, s1); s2 = s1; printf("value = %s, address = %p\n", s2, s2); printf("value = %s, address = %p\n", "Hello World", "Hello World"); return EXIT_SUCCESS; }
时间: 2024-11-07 09:58:51