1、初始化时进行赋值。int a[2] = {1,2};char str[20] = "hello world";2、逐个赋值int a[4];a[0] = 1,a[1]=2, a[2] = 3, a[4]=4;等同于。for (int inx=0; inx!=4; ++inx) a[inx]=inx+1;3、通过函数复制数据以实现赋值比如下面的代码,通过memcpy函数来实现数据的复制,以实现数组赋值的功能。#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int inx;int a[10] = {1,2,3,4,5,6,7,8,9,10};int b[5];//复制4个元素,b[4]将是随机值memcpy(b, a, 4 * sizeof(int));for (inx=0; inx!=5; ++inx) printf("%d\t", b[inx]);printf("\n");memcpy(b, a+4, 5 * sizeof(int));for (inx=0; inx!=5; ++inx) printf("%d\t", b[inx]);printf("\n");return 0;}