c语言中怎么将字符串赋值给变量
-
c语言中怎么将字符串赋值给变量
在C语言中,可以使用strcpy()函数将字符串赋值给变量。例如:#include #include int main() {char str1[20];char str2[] = “Hello, World!”;strcpy(str1, str2);printf(“str1: %s\n”, str1);return 0;}上面的代码中,我们首先定义了两
在C语言中,可以使用strcpy()函数将字符串赋值给变量。例如:#include #include int main() {char str1[20];char str2[] = “Hello, World!”;strcpy(str1, str2);printf(“str1: %s\n”, str1);return 0;}上面的代码中,我们首先定义了两