在C语言中,可以使用strcpy()函数将字符串赋值给变量。例如:
#include <stdio.h>#include <string.h>int main() {char str1[20];char str2[] = "Hello, World!";strcpy(str1, str2);printf("str1: %s\n", str1);return 0;}上面的代码中,我们首先定义了两个字符数组str1和str2,然后使用strcpy()函数将str2中的字符串赋值给str1,最后打印输出str1的值。运行结果为:
str1: Hello, World!上一篇:labview怎么删除重复文件
下一篇:java怎么定义一个字符串数组
c语言









