short C · 关键字
声明短整型变量,通常占用比 int 更少的字节。
怎么用
short 变量名 = 值;
小例子
#include <stdio.h>
int main(void) {
short s = 100;
printf("%hd", s);
return 0;
}
运行结果
输出 100
提醒:具体宽度由实现决定,但至少 16 位;需要确定大小用 int16_t
官方文档:https://en.cppreference.com/w/c/language/arithmetic_types
在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← C全部词条