首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

一个数为128.如何按00128 五位数 输入到字符数组里

2012-03-27 
一个数为128.。怎么按00128 五位数 输入到字符数组里?一个数为128.。怎么按00128 五位数 输入到字符数组里?

一个数为128.。怎么按00128 五位数 输入到字符数组里?
一个数为128.。怎么按00128 五位数 输入到字符数组里?
不足5位的数都前面补0




[解决办法]

C/C++ code
#include<stdio.h>#include<stdlib.h>int main(void){    int num=128;    char buf[10];    sprintf(buf, "%05d", num);    //%05    puts(buf);    return 0;} 

热点排行