C语言中结构体的直接赋值
摘要:
一直记得C语言中,结构体是不可以直接赋值的。我问了三个同学,都说在C++中可以,在C语言中不可以,需要逐一成员赋值或者用memcpy函数。我测试了一下如下的程序:[cpp] view plaincopyprint?#include <stdio.h>#include <stdlib.h>struct test { int a; int b; char ss[10]; }; int main() { struct test t1 = {1, 2, "hello"}; struct test t2; t2 = t1; printf("%d, % 阅读全文
posted @ 2012-08-23 22:17 天外飞仙2 阅读(783) 评论(0) 推荐(0)