typedef用于定义一种新类型
例如
定义了如下的结构
typedef struct student
{
int age;
int score;
}STUDENT;
那么则有
STUDENT stu1;
就相当于struct student stu1;
上面的结构也可以直接定义为:
typedef struct
{
int age;
int score;
}STUDENT;
然后将STUDENT作为新类型使用,比如STUDENT stu1;
typedef声明新的类型来代替已有的类型的名字。
如:
typedef int INTEGER;
下面两行等价
int i;
INTEGER i;
可以声明结构体类型:
typedef struct
{
int age;
int score;
}STUDENT;
定义变量:
只能写成 STUDENT stu;
如果写成
typedef struct student
{
int age;
int score;
}STUDENT;
下面三行等价:
STUDENT stu;
struct student stu;
student stu;
 #include <stdio.h>
#include <ctype.h>
#include <conio.h> void main()
{
char letter; // Letter typed by the user printf("Do you want to continue? (Y/N): "); letter = getch(); // Get the letter
letter = toupper(letter); // Convert letter to uppercase while ((letter != 'Y') && (letter != 'N'))
{
putch(); // Beep the speaker
letter = getch(); // Get the letter
letter = toupper(letter); // Convert letter to uppercase
} printf("\nYour response was %c\n", letter);
}

 

typedef struct 是什么意思的更多相关文章

  1. [转载]彻底弄清struct和typedef struct

    struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int ...

  2. struct和typedef struct彻底明白了

    struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int ...

  3. [C语言]关于struct和typedef struct

    在C中定义一个结构体类型要用typedef: *************************************************************************** t ...

  4. struct和typedef struct用法

    参考:http://www.cnblogs.com/qyaizs/articles/2039101.html C语言: typedef struct Student{ int score; }Stu; ...

  5. struct和typedef struct

    转自:http://www.cnblogs.com/qyaizs/articles/2039101.html struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++ ...

  6. typedef struct 结构体

    typedef struct _TTTT_ {   int    i;  }TT_TT; 定义变量如下: struct _TTTT_  NewTT;方法1 TT_TT NewTT;方法2 是声明和定义 ...

  7. C语言中的struct和typedef struct<转载>

    原文:http://www.nowamagic.net/librarys/veda/detail/1785 typedef为C语言的关键字,作用是为一种数据类型定义一个新名字.这里的数据类型包括内部数 ...

  8. C/C++语法知识:typedef struct 用法详解

    第一篇:typedef struct与struct的区别 1. 基本解释 typedef为C语言的关键字,作用是为一种数据类型定义一个新名字.这里的数据类型包括内部数据类型(int,char等)和自定 ...

  9. struct和typedef struct的区别

    当typedef与结构结合使用时,会有一些比较复杂的情况,而且在C语言和C++里面有略有差别,因此从网上摘录了一些资料. 1 首先:      在C中定义一个结构体类型要用typedef:       ...

  10. typedef struct trx_struct trx_t;

    /* The transaction handle; every session has a trx object which is freed only when the session is fr ...

随机推荐

  1. yum groupinstall "Development Tools" 批量安装软件

    注:可以通过 yum grouplist 来查看可能批量安装哪些列表 从Windows转到Linux下面,一个不习惯的地方就是在图形界面下安装和删除软件的时候非常缓慢.但是如果你掌握了用yum的命令行 ...

  2. 1)Linux学习笔记:crontab命令

    crond简介 crond是linux下用来周期性的执行某种任务或等待处理某些事件的一个守护进程 配置文件 ``` SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin: ...

  3. java数据结构整理(二)

    一.List接口,有序的Collection接口,能够精确地控制每个元素插入的位置,允许有相同的元素 1.链表,LinkedList实现了List接口,允许null元素,提供了get().remove ...

  4. JVM面试

    深入理解Java内存模型:http://www.cnblogs.com/skywang12345/p/3447546.html http://www.infoq.com/cn/articles/jav ...

  5. zMPLS的安装与配置

    1.zmpls的安装 1.1安装环境 ubuntu 12.04 kernel 2.6.35 (对原来的内核进行了替换) 1.2 下载链接 文件zMPLS-0.95-alpha.tar.gz的下载地址为 ...

  6. Sublime Text3 使用手册

    1.标签页切换:ctrl+tab 2.Sublime Text3的配色方案(Preferences——配色方案)我选白色方案是:Eiffel;深色方案我选:Monokai 3.左边资源栏:先ctrl+ ...

  7. Grunt构建工具插件篇——之less工具

    Grunt--Less 摘要: 之前介绍了自动构建工具Grunt,其中有一个模块是"grunt-contrib-less",下面是配置Grunt自动编译less文件. 安装: Gr ...

  8. HTTP Session学习

    session在web开发中是一个非常重要的概念,这个概念很抽象,很难定义,也是最让人迷惑的一个名词,也是最多被滥用的名字之一,在不同的场合,session一次的含义也很不相同.这里只探讨HTTP S ...

  9. 时钟(AnalogClock和DigitalClock)的功能与用法

    时钟UI组件是两个非常简单的组件,DigitalClock本身就继承了TextView——也就是说它本身就是文本框,只是它里面显示的内容总是当前时间.与TextView不同的是为DigitalCloc ...

  10. jquery图片放大镜和遮罩层效果

    图片放大镜效果将借助于jqzoom插件,遮罩层借助于thickbox插件. 1.引入样式表 /*整体样式*/ <link rel="stylesheet" href=&quo ...