C语言中字符串的初始化

字符数组初始化

#include <stdio.h>

int main(void){
    char pork[10] = "pig-meat";
    char dog[] = "dog-meat";
    char cat[] = {'c','a','t','-','m','e','a','t','\0'};
}

通过指针初始化

#include <stdio.h>

int main(void){
    char *b1 = "cat-meat";
    printf("%s",b1);
}

使用strcpy函数初始化

#include <stdio.h>
#include <string.h>

int main(void) {
    char meow[7];
    strcpy(meow, "yyds66");
    printf("%s",meow);
}