Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
static在下面的指针数组声明中添加和不添加关键字有什么区别。
static
static char *list[MAX] = { "Katrina", "Nigel", "Alistair", "Francesca", "Gustav" };
此声明位于main函数内部
main
使用static指针数组将具有静态存储持续时间,没有它将具有自动存储持续时间。在这两种情况下,数组指针元素指向的字符串文字都将具有静态存储持续时间。
鉴于在主函数中声明,除非使用关键字list,否则它将在堆栈上分配。static在任何一种情况下,都不会在堆栈上分配字符串文字。
list