【C++】数据类型 客官°小女子只卖身不卖艺 2022-10-30 06:30 123阅读 0赞 * ### 字节数 ### C++ 32位 64位区别:long 和 指针类型 <table style="width:543px;"> <tbody> <tr> <td style="width:56px;"> </td> <td style="width:49px;"><strong>bool</strong></td> <td style="width:47px;"><strong>char</strong></td> <td style="width:51px;"><strong>short</strong></td> <td style="width:43px;"><strong>int </strong></td> <td style="width:55px;"><strong>float</strong></td> <td style="width:51px;"><strong><span style="color:#f33b45;">long</span></strong></td> <td style="width:41px;"><strong><span style="color:#f33b45;">*</span></strong></td> <td style="width:61px;"><strong>double</strong></td> <td style="width:85px;"><strong>long long</strong></td> </tr> <tr> <td style="width:56px;"><strong>32位</strong></td> <td style="width:49px;"><strong>1</strong></td> <td style="width:47px;"><strong>1</strong></td> <td style="width:51px;"><strong>2</strong></td> <td style="width:43px;"><strong>4</strong></td> <td style="width:55px;"><strong>4</strong></td> <td style="width:51px;"><strong><span style="color:#f33b45;">4</span></strong></td> <td style="width:41px;"><strong><span style="color:#f33b45;">4</span></strong></td> <td style="width:61px;"><strong>8</strong></td> <td style="width:85px;"><strong>8</strong></td> </tr> <tr> <td style="width:56px;"><strong>64位</strong></td> <td style="width:49px;"><strong>1</strong></td> <td style="width:47px;"><strong>1</strong></td> <td style="width:51px;"><strong>2</strong></td> <td style="width:43px;"><strong>4</strong></td> <td style="width:55px;"><strong>4</strong></td> <td style="width:51px;"><strong><span style="color:#f33b45;">8</span></strong></td> <td style="width:41px;"><strong><span style="color:#f33b45;">8</span></strong></td> <td style="width:61px;"><strong>8</strong></td> <td style="width:85px;"><strong>8</strong></td> </tr> </tbody> </table> * ### 进制表示 ### <table style="width:500px;"> <tbody> <tr> <td>B</td> <td>二进制Binary</td> </tr> <tr> <td>O</td> <td>八进制Octal</td> </tr> <tr> <td>D</td> <td>十进制Decimal</td> </tr> <tr> <td>H</td> <td>十六进制Hexadecimal</td> </tr> </tbody> </table> * ### 占位符 ### %d 十进制有符号整数 %ld 长整型 %u 十进制无符号整数 %f 浮点数 %lf double浮点数 %c 单字符 %s 字符串 %p 指针的值 %e 指数形式的浮点数 %x 十六进制无符号整数 %o 八进制无符号整数 %g 自动选择合适表示 **用法:** %3d 输出3位,不够三位右对齐 %04d 输出4位,不够左补0 %9.2f 输出9位,小数2位,小数点1位,整数6位,不够9位右对齐。 如果整数超过,按实际长度输出。如果小数超过,按宽度四舍五入。 %8s 输出8位,不够8位右对齐,如果字符串超过,按实际长度输出 %6.9s 输出 6位<长度<=9位的字符串,超过删除 %-7d 输出7位,左对齐
还没有评论,来说两句吧...