博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

mars

一生何求
  huanghaojie.cublog.cn

关于作者
姓名:Jiangtao
职业:Linux  Support
年龄:26
位置:Shanghai
个性介绍:
|| << >> ||
我的分类


判断int,float,double***占用字节数
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct employee_st {
char name[40];
int id;
} Employee;

int main()
{
int myInt;
Employee john;

printf("Size of int is %d\n",sizeof(myInt));
/* The argument of sizeof is an object */
printf("Size of int is %d\n",sizeof(int));
/* The argument of sizeof is a data type */

printf("Size of Employee is %d\n",sizeof(Employee));
/* The argument of sizeof is a data type */
printf("Size of john is %d\n",sizeof(john));
/* The argument of sizeof is an object */

printf("Size of char is %d\n",sizeof(char));
printf("Size of short is %d\n",sizeof(short));
printf("Size of int is %d\n",sizeof(int));
printf("Size of long is %d\n",sizeof(long));
printf("Size of float is %d\n",sizeof(float));
printf("Size of double is %d\n",sizeof(double));

return 0;

}

[root@tci194 ~]# cc -o a a.c
[root@tci194 ~]# ./a
Size of int is 4
Size of int is 4
Size of Employee is 44
Size of john is 44
Size of char is 1
Size of short is 2
Size of int is 4
Size of long is 4
Size of float is 4
Size of double is 8


发表于: 2007-05-22,修改于: 2007-05-22 19:23,已浏览944次,有评论0条 推荐 投诉


网友评论
 发表评论