在C语言中,你可以使用指针来合并两个数组。以下是一种方法:
int arr1[] = {1, 2, 3, 4, 5};
int arr2[] = {6, 7, 8, 9, 10};
int *mergedArr;
int mergedArrLength = sizeof(arr1) / sizeof(arr1[0]) + sizeof(arr2) / sizeof(arr2[0]);
mergedArr = (int *)malloc(mergedArrLength * sizeof(int));
int i;
for(i = 0; i < sizeof(arr1)/sizeof(arr1[0]); i++){
mergedArr[i] = arr1[i];
}
for(i = 0; i < sizeof(arr2)/sizeof(arr2[0]); i++){
mergedArr[sizeof(arr1)/sizeof(arr1[0]) + i] = arr2[i];
}
for(i = 0; i < mergedArrLength; i++){
printf("%d ", mergedArr[i]);
}
free(mergedArr);
上述代码会将两个数组arr1和arr2合并成一个新的数组,并通过指针mergedArr来访问合并后数组的元素。