标签:
1 #include "stdio.h" 2 3 #include "stdlib.h" 4 5 6 7 int main(void) 8 9 { 10 11 int num = 10; 12 13 char str[100]; 14 15 itoa(num, str, 8); //将整数10转换为八进制保存在str字符数组中 16 17 printf("%s\n", str); 18 19 system("pause"); 20 21 return 0; 22 23 }
1 #include "stdio.h" 2 3 #include "stdlib.h" 4 5 6 7 int main(void) 8 9 { 10 11 int num = 15; 12 13 char str[100]; 14 15 int n = atoi(itoa(num, str, 2)); //先把num转换为二进制的字符串,再把该字符串转换为整数 16 17 printf("%d\n",n); 18 19 system("pause"); 20 21 return 0; 22 }
标签:
原文地址:http://www.cnblogs.com/wangmengmeng/p/4575148.html