📜  字符串格式小数位c++代码示例

📅  最后修改于: 2022-03-11 14:44:45.412000             🧑  作者: Mango

代码示例1
//%f     // placeholder for a float value
//%.2f     //as a placeholder, your float will be written rounded to 2 decimal places
        // if you require a truncated representation, consider
        // integer division or std::trunc() from  or 

// example string:
printf("Your total is $%.2f", 30.999);
//output:
//Your total is $31.00