博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C语言->参数类型所占字节数计算
阅读量:2140 次
发布时间:2019-04-30

本文共 570 字,大约阅读时间需要 1 分钟。

C语言各参数类型所占字节数计算

#include  
struct student{ double aaa; int bbb; char ccc;};int main(){ struct student A; // #if 1 printf("aaa的偏移地址为:%d\n",&A.aaa); printf("bbb的偏移地址为:%d\n",&A.bbb); printf("ccc的偏移地址为:%d\n",&A.ccc); #endif // printf("double型变量所占内存%d\n",sizeof(double)); //8个字节 printf("int 所占内存%d\n",sizeof(int)); //4个字节 printf("char 所占内存%d\n",sizeof(char)); //1个字节 printf("结构体变量A所占内存%d\n",sizeof(A)); //结构体变量A所占内存空间始终大于结构的大小,原因是因为内存对齐 return 0; //sizeof(A) 结果16}

 

转载地址:http://kdtgf.baihongyu.com/

你可能感兴趣的文章
剑指offer 25.二叉树中和为某一值的路径
查看>>
剑指offer 60. 不用加减乘除做加法
查看>>
Leetcode C++《热题 Hot 100-13》234.回文链表
查看>>
Leetcode C++《热题 Hot 100-14》283.移动零
查看>>
Leetcode C++《热题 Hot 100-15》437.路径总和III
查看>>
Leetcode C++《热题 Hot 100-17》461.汉明距离
查看>>
Leetcode C++《热题 Hot 100-18》538.把二叉搜索树转换为累加树
查看>>
Leetcode C++《热题 Hot 100-19》543.二叉树的直径
查看>>
Leetcode C++《热题 Hot 100-21》581.最短无序连续子数组
查看>>
Leetcode C++《热题 Hot 100-22》2.两数相加
查看>>
Leetcode C++《热题 Hot 100-23》3.无重复字符的最长子串
查看>>
Leetcode C++《热题 Hot 100-24》5.最长回文子串
查看>>
Leetcode C++《热题 Hot 100-26》15.三数之和
查看>>
Leetcode C++《热题 Hot 100-28》19.删除链表的倒数第N个节点
查看>>
Leetcode C++《热题 Hot 100-29》22.括号生成
查看>>
Leetcode C++《热题 Hot 100-40》64.最小路径和
查看>>
Leetcode C++《热题 Hot 100-41》75.颜色分类
查看>>
Leetcode C++《热题 Hot 100-42》78.子集
查看>>
Leetcode C++《热题 Hot 100-43》94.二叉树的中序遍历
查看>>
Leetcode C++ 《第175场周赛-1 》5332.检查整数及其两倍数是否存在
查看>>