📜  如何在 C 编程语言代码示例中返回 char 数组

📅  最后修改于: 2022-03-11 15:04:41.628000             🧑  作者: Mango

代码示例4
#include 
#include 
    char* createStr(){
    static char str[20] = "my";
    return str;
}
int main(){
    char a[20];
    strcpy(a,createStr()); //this will copy the returned value of createStr() into a[]
    printf("%s",a);
    return 0;
}