typedef struct 是什么意思

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;
 1 #include <stdio.h>
 2 #include <ctype.h>
 3 #include <conio.h>
 4 
 5 void main()
 6 {
 7     char letter;  // Letter typed by the user
 8 
 9     printf("Do you want to continue? (Y/N): ");
10 
11     letter = getch();          // Get the letter  
12     letter = toupper(letter);  // Convert letter to uppercase
13 
14     while ((letter != 'Y') && (letter != 'N'))
15     {
16         putch(3);                  // Beep the speaker
17         letter = getch();          // Get the letter  
18         letter = toupper(letter);  // Convert letter to uppercase
19     }
20 
21     printf("\nYour response was %c\n", letter);
22 }
 
 

 

 

转载于:https://www.cnblogs.com/Zblogs/p/3361100.html

  • 8
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值