为什么我不能指定数组作为&放大器; A =和B? [英] Why can't I assign arrays as &a = &b?
本文介绍了为什么我不能指定数组作为&放大器; A =和B?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有像分配一个数组的一个问题:
I have a problem assigning an array like:
int a[];
int b[] = {1,2,3};
&a = &b;
我知道我可以使用指针,但我想尝试一下这种方式...
I know I could use pointers but I want to try it that way...
推荐答案
您无法分配在C数组你可以用的memcpy复制它们()
功能,在声明<&string.h中GT;
:
You can't assign arrays in C. You can copy them with the memcpy()
function, declared in <string.h>
:
int a[3];
int b[] = {1,2,3};
memcpy(&a, &b, sizeof a);
这篇关于为什么我不能指定数组作为&放大器; A =和B?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文