结构体
结构体是 C 语言主要的自定义类型方案,这篇就来认识一下结构体。
一、结构体的形态
C源程序(struct.c):
#include <stdio.h>
typedef struct{
unsigned short int a;
unsigned short int b;
}Data;
int main()
{
Data c, d;
c.a = 1;
c.b = 2;
d = c;
printf("d.a:%d\nd.b:%d\n", d.a, d.b);
return 0;
}
赋值部分翻译后:
movw $1, 28(%esp) # c.a = 1
movw $2, 30(%esp) # c.b = 2
movl 28(%esp), %eax #
movl %eax, 24(%......
阅读全文