#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));

}

 转载请注明出处: http://www.cnblogs.com/xlutech/p/c_uint32_to_str.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2021-12-17
猜你喜欢
  • 2022-12-23
  • 2021-12-24
  • 2022-02-08
  • 2022-03-03
  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
相关资源
相似解决方案