printf 详解 笔记

先看代码:

#include <stdio.h>
#define INTDEMO 250

int main()
{
    const double DOUBLEDEMO = 3.14159;
    const short SHORTDEMO = 0xFFFF;

    printf("%2d\n",INTDEMO);
    printf("%10d\n", INTDEMO);
    printf("%-10d\n",INTDEMO);

    printf("%f\n", DOUBLEDEMO);
    printf("%Lf\n", DOUBLEDEMO);
    printf("%4.2Lf\n", DOUBLEDEMO);
    printf("%10.3Le\n", DOUBLEDEMO);
    printf("%10.3Lf\n", DOUBLEDEMO);
    printf("%010.3Lf\n", DOUBLEDEMO);
    printf("%+010.3Lf\n", DOUBLEDEMO);

    printf("%c", SHORTDEMO);

    float f_num = 3.0;
    double d_num = 3.0;
    int i_num = 2000000000;
    long l_num = 1234567890;

    printf("%.1g %.1g %.1g %.1g", f_num, d_num, i_num, l_num);
    printf("%ld %ld", i_num, l_num);
    printf("%ld %ld %ld %ld", f_num, d_num, i_num, l_num);

    printf("I""Love", "Mark");




    getchar();
    
    return 0;
}

 

 

运行得出:

 

posted on 2016-09-17 13:42  zzdoit  阅读(176)  评论(0编辑  收藏  举报

导航