itoa随手记(itoa是什么,itoa怎么用)

简介: itoa随手记(itoa是什么,itoa怎么用)

前言

虽然是非常常见的函数,但我没见过,在这里记录一下。


一、itoa是什么?

itoa函数,全称int to array,是将整形转换成字符串类型的函数。是C非标准库的函数(写题目也不用管这个)

二、使用

char* itoa(int value,char*string,int radix);

value: 要转换的整数,可以不是int类型但是整数必须在int的范围里           string: 转换后的字符串  radix: 转换进制数,范围是2~36

1. #include <stdio.h>
2. int main()
3. {
4.  int number1 = 12;
5.  int number2 = -123456;
6.  char string[16] = {0};
7.  itoa(number1,string,8);
8.  printf("数字:%d 转换为:%s\n",number1,string);
9.  itoa(number2,string,10);
10.   printf("数字:%d 转换为:%s\n",number2,string);
11. system("pause");
12.   return 0;
13. }


总结

用于int类型转字符串

填入数字的范围在int之内,可以是负数,进制转化在2到36之间。

相关文章
|
3月前
|
安全
一文搞懂:_itoa_itow_itotatoiatofatol
一文搞懂:_itoa_itow_itotatoiatofatol
21 0
|
3月前
|
安全 编译器 C语言
C语言学习记录——字符串相关函数及部分模拟(strcmp、strncmp、strncat、strncpy、strstr、strtok、strerror)
C语言学习记录——字符串相关函数及部分模拟(strcmp、strncmp、strncat、strncpy、strstr、strtok、strerror)
31 1
|
4月前
|
C语言
C语言进阶⑬(字符串函数)+(指针编程题)strlen+strcpy+strcat+strstr+strtok+strerror(上)
C语言进阶⑬(字符串函数)+(指针编程题)strlen+strcpy+strcat+strstr+strtok+strerror
27 0
|
4月前
|
C语言
C语言进阶⑬(字符串函数)+(指针编程题)strlen+strcpy+strcat+strstr+strtok+strerror(下)
C语言进阶⑬(字符串函数)+(指针编程题)strlen+strcpy+strcat+strstr+strtok+strerror
19 0
|
4月前
|
安全 C语言
C语言进阶⑬(字符串函数)+(指针编程题)strlen+strcpy+strcat+strstr+strtok+strerror(中)
C语言进阶⑬(字符串函数)+(指针编程题)strlen+strcpy+strcat+strstr+strtok+strerror
37 0
|
编译器 C语言
【C语言进阶】字符函数及字符串函数,带你掌握核心用法并模拟实现(1)——strlen,strcpy,strcmp
【C语言进阶】字符函数及字符串函数,带你掌握核心用法并模拟实现(1)——strlen,strcpy,strcmp
126 1
|
API C语言
利用strstr与atoi的结合实现一个C语言获取文件中数据的工具
利用strstr与atoi的结合实现一个C语言获取文件中数据的工具
47 0
|
编译器 C语言
C语言strlen,strcpy ,strcat, strcmp,strstr常用库函数的理解与模拟实现
C语言strlen,strcpy ,strcat, strcmp,strstr常用库函数的理解与模拟实现
122 0
|
算法 编译器 C语言
少见却强大酷炫的字符串函数(strtok/strstr/strerror)
正片开始👀 字符串函数👏 首先神魔是字符串函数?
少见却强大酷炫的字符串函数(strtok/strstr/strerror)
|
Java C语言
每日一练(37):实现 strStr()
实现 strStr() 函数。
228 0