在修改别人的代码的过程中,发现很多人会把struct和struct的定义混淆,在这里主要是为了提醒自己Struct定义的规范性。

#include <stdio.h>

struct x{
int a;
char b;
}; typedef struct g{
int a;
char b;
}G; int main()
{
int a;
char b;
int m = sizeof(a);
int n = sizeof(b);
printf("size of int is %d\n", m);
printf("size of char is %d\n", n);
int x = sizeof(x);
int y = sizeof(G);
printf("size of struct is %d\n", x);
printf("size of struct G is %d\n", y);
return 0;
}

  运行的结果为:

在这里Struct G的大小为8是因为:字节对齐,说明Struct在默认情况下,就已经做了字节对齐。

最新文章

  1. RubyMine优化设置
  2. LR12.53—第6课:运行负载测试
  3. samba 最简单配置 共享
  4. [SAP ABAP开发技术总结]IDoc
  5. javascript读取本地文件
  6. Delphi获取当前系统时间(使用API函数GetSystemTime)
  7. unity 调用android函数
  8. 将项目(代码)从GitHub上克隆(下载)到本地仓库
  9. php 将图片转成base64
  10. Angular中ui-router实现路由嵌套案例
  11. 前端、数据库、Django简单的练习
  12. mysql学习之路_视图
  13. Linux内核系统体系概述
  14. 华为手机使用objectAnimation异常
  15. 【剑指offer】用两个栈实现队列
  16. python之旅:字符编码
  17. oracle中如何把结果集插入临时表中
  18. SP263 PERIOD - Period
  19. 【Android】Android 学习记录贴
  20. excel linux扩展

热门文章

  1. 集合之四:List接口
  2. reset.css(重置浏览器默认样式)
  3. Windows USB 编程
  4. 解决执行maven项目出现 SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”. error
  5. STM32的固件升级(RTT
  6. pycharm安装与使用
  7. execution(* *..BookManager.save(..))的解读
  8. Bash编程(4) 参数与变量
  9. 如何限制html标签input的长度
  10. 解决 Java 调用 Azure SDK 证书错误 javax.net.ssl.SSLHandshakeException