C Primer Plus 6th c语言笔记
文章目录
常用知识:
编译 :
gcc hello.c -o hello运行 :
./hello.outC99 标准中main函数返回必须为int型,而不是void型。
bit: 0或者1.
byte:8-bit,最大255.
char:But it is integer type,Why?Because the char type actually stores integers. Use ASCII code for example the integer value 65 represents an uppercase A. The standard ASCII code runs numerically from 0 to 127, So char is 8-bit unit pf memory. 例如’A’,使用单引号。
默认是有符号的,如果超过了就会变成无符号值,如果实在超过了就变成long或者longlong。
Octal: 八进制,%o,%#o(可以保留数值前面的0).
Hexadecimal:十六进制,%x,%#x(可以保留数值前面的0x).
现在个人电脑一般的设置是longlong是64bits,long是32bits,int是16bits或者32bits,short是16bits。主要看机器位数。
把小数值作为大数值存储:例如7L(此时7就是long型), 7LL(此时7就是long long型), 7LLU或者7ull(此时7就是unsigned long long型).signed int number: %d
unsigned int number: %u
signed long number: %ld
unsigned long number: %lu
signed short number: %hd
| bits | signed | unsigned | number |
|---|---|---|---|
| 8bits | -127~127 | 255 | 百位 |
| 16bits | -32767~32767 | 65535 | 万位 |
| 32bits | –2,147,483,647 ~2,147,483,647 | 4,294,967,295 | 十亿位 |
| 64bits | –9,223,372,036,854,775,807~9,223,372,036,854,775,807 | 18,446,744,073,709,551,615 | 好大 |
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论