hal_uart_rxcpltcallback配置与调试手把手教程
2025/12/28 8:09:44
| 类型 | 关键字 | 字节 | 取值范围 |
|---|---|---|---|
| 字符 | char | 1 | -128 ~ 127 |
| 短整型 | short | 2 | -32768 ~ 32767 |
| 整型 | int | 4 | -2,147,483,648 ~ 2,147,483,647 |
| 长整型 | long | 4 | 同int |
| 长长整型 | long long | 8 | -9.22×10¹⁸ ~ 9.22×10¹⁸ |
| 类型 | 关键字 | 字节 | 取值范围 |
|---|---|---|---|
| 无符号字符 | unsigned char | 1 | 0 ~ 255 |
| 无符号短整型 | unsigned short | 2 | 0 ~ 65535 |
类型名 变量名;类型名 变量名1,变量名2,变量名3;示例:
intcount;floatpercent,total;intcount;count=0;intcount=0;doublepercent=0.01;typedefintinteger;integer count;// 等同于 int count;intcount=20;// 20是整型字面常量floattax=0.28;// 0.28是浮点型字面常量#definePI3.14159#defineMAX_SIZE100constfloatPI=3.14159;constintMAX=100;constintcount=100;count=200;// 错误!不能修改const变量#include<stdio.h>#defineLAPS_PER_MILE4// #define定义的符号常量constintCURRENT_YEAR=2013;// const定义的符号常量floatmiles_covered;intlaps_run,year_of_birth,current_age;intmain(void){printf("How many laps did you run: ");scanf("%d",&laps_run);printf("Enter your year of birth: ");scanf("%d",&year_of_birth);miles_covered=(float)laps_run/LAPS_PER_MILE;// 使用符号常量current_age=CURRENT_YEAR-year_of_birth;// 使用符号常量printf("\nYou ran %.2f miles.",miles_covered);printf("\nNot bad for someone turning %d this year!\n",current_age);return0;}