linux 数据类型

1.整形: 用%d打印                                                                          2.字符型                                                                        3.浮点型

在32位操作系统中:                                                字符型对应不同的ASCII码 ,                                            有double和float,double为双精度,float为单精度,  

int:4字节                                                                 例如:     用%c或%d打印                                                                            float 表示的范围小,精度低(小数点后6位)

short:2字节                                                        #include <stdio.h>                                                                   double表示的范围大,精度高(小数点后16位)

long: 4字节                                                                int main()                                                                          printf打印float或double  用%f

double:8字节                                                    {

float:8字节                                                              char  c1='A';

long long:8字节                                                         printf ("c1=%d,c1=%c.\n",c1,c1); 

char:1字节                                                           }

验证方式                                                                         这俩个c1  为不同的输出  前一个为65 后一个为A。

 #include <stdio.h>

 int main()
 {
       printf ("long size is %d\n", sizeof (short));
       printf ("int size is %d\n", sizeof (int));
       printf ("long size is %d\n", sizeof (long));
       printf ("double size is %d\n", sizeof (double));
       printf ("float size is %d\n", sizeof (float));
       printf ("char size is %d\n", sizeof (char));
  
      return 0;                                             

整形代码                                                       浮点型代码       

#include <stdio.h>                                         #include <stdio.h>

int main()                                                        int main()

{                                                                    {

    int a;                                                            printf ("%f\n", 10.5);

    int b;                                                             printf ("%10.3f\n", 10.5);       // 右对齐

    int c;                                                            
                                                                        printf ("%010.3f\n", 10.5);      // 右对齐,不够位数自动补0                                                      

    a=12;                                                           printf ("%2.3f\n", 10.5);        // 右对齐,不够位数自动补0

     b=23;                                                          return 0;

     c=a+b;                                                        }

     printf("c=%d.\n",c);

     return 0;

}

}
 13

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值