首页 > 其他 > 详细

uint32转为string

时间:2014-03-03 17:53:17      阅读:1177      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <inttypes.h>
#include <sys/types.h>

int
main(int argc, char const *argv[])
{
     char str[11]; /* 11 bytes: 10 for the digits, 1 for the null character */
     uint32_t n = 1;
     snprintf(str, sizeof str, "%lu", (unsigned long)n); /* Method 1 */
     printf("s1 = %s, strlen = %u\n", str, (unsigned)strlen(str));

     snprintf(str, sizeof str, "%" PRIu32, n); /* Method 2 */
     printf("s2 = %s, strlen = %u\n", str, (unsigned)strlen(str));

}
bubuko.com,布布扣

uint32转为string,布布扣,bubuko.com

uint32转为string

原文:http://www.cnblogs.com/xlutech/p/c_uint32_to_str.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!