control character length

/* 
     * written by raymond
     * Copyright 2013
    */
    #include <stdio.h>
    int main(void){
        float plank_length=10.0f;
        float piece_count=4.0f;
        float piece_length=0.0f;
        piece_length=plank_length/piece_count;
        printf("%1.2f,%5.0f,%6.2f\n", plank_length,piece_count,piece_length);
        //print(space should be noticed):
        //10.00,    4,  2.50
        //%[width][.precision][modifier]f
        //note1:width=>whole length
        //note2:. is also a character
        //note3:if printing the type is 'long double',modifier equal 'L',otherwise can ignore it.

    return 0;
}

 

posted on 2019-02-25 15:30  鸣动我心  阅读(129)  评论(0编辑  收藏  举报