C语言入门 - 基本数据类型

#include<stdio.h>
#include<unistd.h>//linux环境下
//#include<Windows.h>//
//#include"haha.txt"

void main()

{    //数据类型、格式字符、转义字符

    
    int b = 10;       //4 byte  -(1 byte = 8 bit)
    short b1 = 100;   //2 byte
    long  b2 = 1000;   //2 byte
   
    char a = 'a';  //1 byte

    float c = 1.00;//4 byte
    double d = 4.5;//8 byte

    char *p = "hello";
    
    printf("int =%d\n",b);
    printf("short =%d\n",b1);
    printf("long  =%d\n",b2);

    printf("char =%c\n",a);

    printf("float =%f\n",c);
    printf("double  =%lf\n",d);
    
    printf("char * =%s\n",p);

    printf("b八进制:%o\n",b);
    printf("b十进制:%d\n",b);
    printf("b十六进制:%x\n",b);

    printf("char &a:%x\n",&a);
    printf("&b八进制:%o\n",&b);
    printf("&b十进制:%d\n",b);
    printf("&b十六进制:%x\n",&b);

    printf("& *p十六进制:%x\n",p);

    sleep(2);
    //return ;
    //
    
}

猜你喜欢

转载自blog.csdn.net/Naiva/article/details/84495138