c++将数字转换成固定长度的字符串

c++将数字转换成固定长度的字符串

 将数字转换为字符串,且设置为固定长度的,不足补零。

string num2str(int i)
{
    char ss[10];
    sprintf(ss,"%04d",i);
    return ss;
}

参考

1.

https://blog.csdn.net/m0_37733057/article/details/79035923

猜你喜欢

转载自www.cnblogs.com/happyamyhope/p/10298123.html