atoi (表示 ascii to integer)是把字符串转换成整型数的一个函数。
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
int n;
char *str = "12345.67";
n = atoi(str);
printf("n=%d\n",n); //n = 12345.67
return 0;
}
把十进制整数或浮点数转换为字符串。
#include <iostream>
#include <string>
int main()
{
double f = 23.43;
std::string f_str = std::to_string(f);
std::cout << f_str << '\n'; //23.430000
}
博客介绍了 atoi 函数,它可将字符串转换成整型数,同时还提及把十进制整数或浮点数转换为字符串的内容,聚焦于字符串与整型数的转换。
922

被折叠的 条评论
为什么被折叠?



