在C语言中,可以通过以下方式赋值字符串:
char str[10];
strcpy(str, "Hello");
char *str;
str = "Hello";
char str[10];
str[0] = 'H';
str[1] = 'e';
str[2] = 'l';
str[3] = 'l';
str[4] = 'o';
str[5] = '\0'; // 字符串以空字符结尾
注意:
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: c语言字符串如何存入数组