当前位置:网站首页>Convert numbers to string strings (to_string()) convert strings to int sharp tools stoi();
Convert numbers to string strings (to_string()) convert strings to int sharp tools stoi();
2022-07-07 05:59:00 【Grow your own flowers 111】
C++ Medium to_string()
The series of functions will Convert numeric values to strings form .
The header file :#include<string>
string s = to_string(n); // The integer n Convert to string String representation
to_string()
The prototypes of all functions are as follows :string to_string (int val);
string to_string (long val);
string to_string (long long val);
string to_string (unsigned val);
string to_string (unsigned long val);
string to_string (unsigned long long val);
string to_string (float val);
string to_string (double val);
string to_string (long double val);
Example :
#include <iostream>
#include <string>
using namespace std;
int main() {
int a = 4876867;
string str= to_string(a);
cout << str;
return 0;
}
After operation :
character string str=4876867;
take String conversion to int Type sharp weapon stoi();
stoi();
#include <iostream>
#include <string>
using namespace std;
int main() {
string a="15135";
int n=stoi(a);
cout<<n;
}
Output n=15135;
边栏推荐
- zabbix_get测试数据库失败
- Go 语言的 Context 详解
- yarn入门(一篇就够了)
- 【FPGA教程案例14】基于vivado核的FIR滤波器设计与实现
- R language [logic control] [mathematical operation]
- Classic questions about data storage
- Flask1.1.4 Werkzeug1.0.1 源码分析:启动流程
- PTA ladder game exercise set l2-002 linked list de duplication
- 980. Different path III DFS
- Introduction to distributed transactions
猜你喜欢
随机推荐
Data storage 3
@pathvariable 和 @Requestparam的详细区别
Interview skills of software testing
Value range of various datetimes in SQL Server 2008
How to improve website weight
【FPGA教程案例14】基于vivado核的FIR滤波器设计与实现
Polynomial locus of order 5
Pytorch builds neural network to predict temperature
C. colonne Swapping [tri + Simulation]
Introduction to distributed transactions
从“跑分神器”到数据平台,鲁大师开启演进之路
[shell] clean up nohup Out file
2pc of distributed transaction solution
毕业之后才知道的——知网查重原理以及降重举例
STM32 key state machine 2 - state simplification and long press function addition
PTA ladder game exercise set l2-004 search tree judgment
Five core elements of architecture design
Understand the deserialization principle of fastjson for generics
CMD permanently delete specified folders and files
Hcip seventh operation