分配一个结构到另一个用C [英] Assign one struct to another in C
本文介绍了分配一个结构到另一个用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您可以一个结构的一个实例分配给另一个,就像这样:
Can you assign one instance of a struct to another, like so:
struct Test t1;
struct Test t2;
t2 = t1;
我已经看到它结构简单工作,卜它对于复杂结构工作?结果
编译器如何知道根据不同的类型,即 INT
和字符串?
推荐答案
是如果结构是相同类型的。想想它作为一个内存拷贝。
Yes if the structure is of the same type. Think it as a memory copy.
这篇关于分配一个结构到另一个用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文