《初学C语言第13天》
/////////生成随机数
/////time---对应头文件#include<time.h>
//// srand
//#include<stdio.h>
//#include<time.h>
//#include<stdlib.h>
//int main()
//{
// srand(2);
// printf("%d\n",rand());
// printf("%d\n", rand());
// printf("%d\n", rand());
// printf("%d\n", rand());
// printf("%d\n", rand());
// return 0;
//}
//--------结构体
// struct tag
//{
// member - list;//成员列表
//}variable - list;//变量列表
//要描述一个学生
//信息
//名字
//年龄
//电话
//性别
//struct--结构体关键字 stu--结构体标签。struct stu结构体类型
//struct stu//定义一个结构体类型近似于int(不占用空间,没有变量的产生————————近似于图纸)
//{
// //成员变量
// char name[20];
// short age;
// char tele[12];
// char sex[5];
//}s1,s2,s3;//s1,s2,s3为三个全局结构体变量,都是struct stu类型//分号不能丢
//int main()
//{
// //创建.结构体变量(盖房子)
// struct stu s;//s:局部变量
// return 0;
//}
typedef struct stu//定义一个结构体类型近似于int(不占用空间,没有变量的产生————————近似于图纸)
{
//成员变量
char name[20];
short age;
char tele[12];
char sex[5];
}stu;//typedef把“struct stu”改了个名字,叫stu类型
int main()
{
//创建.结构体变量(盖房子)
stu s1;//s:局部变量
stu s2;
return 0;
}
上一篇: 【C语言】宏定义
下一篇: Rust 能够取代 C 语言吗?