函數以數組爲返回值

#include <stdio.h> char *func() { static char a[] = "hello world"; return a; } int main() { printf("%s\n", func()); return 0; } 由下圖可知,當字符串數組a定義成靜態的時候,它的生命週期與程序的生命週期一樣。 若不定義成 static 型,則
相關文章
相關標籤/搜索