C语言 Printf函数

 

 

#include <stdio.h>

int main(int argc, const char * argv[])
{

    // insert code here...
    printf("Hello, World!\n");
    
    
    
    printf("My age is %d\n", 26);
    
    // My age is 26,height is 1.55,name is 名字,sex is 'A'
    printf("My age is %-4d,height is %-5.2f,name is %s,sex is '%c'",
           26, 1.55f, "名字", 'A');
    
    // %.2f代表保留2位小数
    
    // 一个中文会占用至少2个字符
    
    
    
    return 0;
}

 

posted on 2017-05-24 15:54  守望星空  阅读(146)  评论(0编辑  收藏  举报

导航