2016年3月3日

利用C语言结构体模拟一个简单的JavaBean

摘要: 利用C语言模拟一个Javabean 仅封装了,“无参构造函数”,“带参构造函数”,"toString方法" #include <stdio.h> struct User{ int ID; char *name; char *password; int age; }; void newUser(str 阅读全文

posted @ 2016-03-03 22:31 木鸟飞 阅读(703) 评论(0) 推荐(0)

结构体赋值

摘要: #include <stdio.h> struct student{ int ID; char name[48]; int age; }; int main(){ struct student s1 = { 1, "lifei", 24 }; struct student s2; s2 = s1; 阅读全文

posted @ 2016-03-03 22:27 木鸟飞 阅读(682) 评论(0) 推荐(0)

C语言结构体赋值2

摘要: #include <stdio.h> /** 上一个版本的name是固定大小的,不好,这次换用 *name然后 采用 堆的方式申请内存,起到用到少拿多少的一个方式。 */ struct student{ int ID; char *name; int age; }; struct test{ cha 阅读全文

posted @ 2016-03-03 22:27 木鸟飞 阅读(463) 评论(0) 推荐(0)

结构体所占内存大小

摘要: 结构体所占内存大小划分原则: 1、划分字节,按照当前结构体中,字节数最大的类型作为划分单元。【这里面还有一些前提。下面的例子会详细说到】 2、以矩形块儿的形式划分。 /**划分示意图: 最小单元是 double所以 这个 地方按照8个字节作为最小单元来划分。 */ /**划分示意图: 最小单元不能是 阅读全文

posted @ 2016-03-03 22:26 木鸟飞 阅读(752) 评论(0) 推荐(0)

C语言结构体的引入

摘要: #include <stdio.h> struct student{ int ID; char name[48]; int age; }; int main(){ //赋值: struct student s1 = { 1, "lifei", 24 }; struct student s2 = { 阅读全文

posted @ 2016-03-03 22:23 木鸟飞 阅读(367) 评论(0) 推荐(0)

导航