zoukankan      html  css  js  c++  java
  • 004 C/C++ 数据类型_类型别名

     1 #include "stdio.h"
     2 #include "stdlib.h"
     3 
     4 //这里定义了一个结构体.
     5 struct MyStruct1
     6 {
     7     int a;
     8     float b;
     9 };
    10 
    11 // 这里定义了一个结构体和它的别名.
    12 typedef struct MyStruct2
    13 {
    14     int a;
    15     float b;
    16 } MyStruct2;
    17 
    18 //定义简单数据类型的别名
    19 typedef int u32;
    20 
    21 void main()
    22 {
    23     //MyStruct1 a;        //在c中这是错误的编译不通过. C++中对struct有增强可以这样写.
    24     struct MyStruct1 a; //在C中正确写法.
    25     MyStruct2 b;        
    26     u32 c;
    27     printf( "sizeof(a):%d, sizeof(b):%d, sizeof(c):%d 
    ", sizeof( a ), sizeof( b ), sizeof( c ) );
    28     system( "pause" );
    29 }

    Output Result:

    output result:
    sizeof(a):8, sizeof(b):8, sizeof(c):4
    请按任意键继续. . .
    致读者:本人自学编程,知识薄弱,实践经验不够,博客文章难免有错误之处,希望读者能积极指正,感激不尽。 若您有更精妙的解决方案或者对文中有疑问,欢迎留言或联系我讨论问题。
  • 相关阅读:
    浏览器检测
    EcmaScript基础
    js中的内置对象
    cursor 与refcursor及sys_refcursor的区别 (转载)
    各种连接数据方法的网站
    UVa11627 Slalom
    UVa1450 Airport
    UVa12124 Assemble
    UVa11384 Help is needed for Dexter
    UVa11464 Even Parity
  • 原文地址:https://www.cnblogs.com/it89/p/11069514.html
Copyright © 2011-2022 走看看