C/C++整数输出位不足前补0方法

头文件:<iomanip>

函数:setw(int n)

函数:setfill(char c)

cout<<setw(8)<<setfill('0')<<123<<endl;

输出:00000123

C语言

头文件: <stdio.h>

printf("%08d ",123);

输出:00000123

原文地址:https://www.cnblogs.com/covei/p/13689943.html