码迷,mamicode.com
首页 > 其他好文 > 详细

printf 详解 笔记

时间:2016-09-17 14:56:09      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

先看代码:

#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;
}

 

 

运行得出:

技术分享

 

printf 详解 笔记

标签:

原文地址:http://www.cnblogs.com/bing-z/p/5875083.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!