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. 批量检查APK是否具有指定的权限。

    为测试组的妹子提供的. 效果如下: 目录结构如下: 源代码思路: 1.将apk文件变为zip文件.这里是修改后缀 2.解压文件到指定目录.可以只解压其中mainfest.xml文件 3.移动xml文件 ...

  2. java实现FFT变换(转)

    源:java实现FFT变换 /************************************************************************* * Compilati ...

  3. python内置函数all使用的坑

    在代码的改造过程中,因为忽略了一个问题导致数据异常,在改造的过程中以及后续的review中都没注意到这个问题,单元测试也没有覆盖到,记录如下.这个坑在于all的使用上,如果参数为空元组或空列表时,返回 ...

  4. bzoj 4383: [POI2015]Pustynia

    复习了一下线段树优化建图的姿势,在线段树上连边跑拓扑排序 这题竟然卡vector……丧病 #include <bits/stdc++.h> #define N 1810000 using ...

  5. MAC中使用Vim和GCC编译C程序

    1.打开终端 2.输入以下命令进入vim编辑器: vim a.c 3.进入编辑器后按i进入insert模式,然后键入以下代码: #include<stdio.h> int main(){ ...

  6. gridview属性

    1.列头充满:AutoSizeColumnsMode, Fill. 2.列内容居中:ColumnHeadersDefaultCellStyle, MiddleCenter. 3.行内容居中:RowsD ...

  7. hashchange

    <!DOCTYPE html> <html> <head> <title>Hash Change Example</title> <s ...

  8. Discuz经典函数注释之authcode

    Discuz函数中最经典的函数是authcode函数,因为supesite,UCenterHome,UCenter,Discuz X都使用了这个函数进行加密啊传输串与cookie 今天为大家带来aut ...

  9. 让php Session 存入 redis 配置方法

    首先要做的就是安装redis 安装方法:http://redis.io/download Installation Download, extract and compile Redis with: ...

  10. jQuery按键事件响应的Demo

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...