当前位置:网站首页>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;
边栏推荐
- C. colonne Swapping [tri + Simulation]
- Differences and introduction of cluster, distributed and microservice
- Hcip seventh operation
- 【日常训练--腾讯精选50】292. Nim 游戏
- [daily training -- Tencent selected 50] 292 Nim games
- The solution of a simple algebraic problem
- Things about data storage 2
- 【FPGA教程案例14】基于vivado核的FIR滤波器设计与实现
- pytorch_ 01 automatic derivation mechanism
- 谈fpga和asic的区别
猜你喜欢
Interview skills of software testing
PTA ladder game exercise set l2-004 search tree judgment
Why does the data center need a set of infrastructure visual management system
Say sqlyog deceived me!
The solution of a simple algebraic problem
一个简单的代数问题的求解
Understand the deserialization principle of fastjson for generics
[daily training -- Tencent selected 50] 235 Nearest common ancestor of binary search tree
力扣102题:二叉树的层序遍历
如果不知道这4种缓存模式,敢说懂缓存吗?
随机推荐
Reptile exercises (III)
Flask1.1.4 Werkzeug1.0.1 源码分析:启动流程
Go language context explanation
【日常训练--腾讯精选50】235. 二叉搜索树的最近公共祖先
How to get free traffic in pinduoduo new store and what links need to be optimized in order to effectively improve the free traffic in the store
SQL query: subtract the previous row from the next row and make corresponding calculations
Add salt and pepper noise or Gaussian noise to the picture
目标检测中的BBox 回归损失函数-L2,smooth L1,IoU,GIoU,DIoU,CIoU,Focal-EIoU,Alpha-IoU,SIoU
SAP Spartacus checkout 流程的扩展(extend)实现介绍
SQLSTATE[HY000][1130] Host ‘host. docker. internal‘ is not allowed to connect to this MySQL server
Data storage 3
线性回归
[solved] record an error in easyexcel [when reading the XLS file, no error will be reported when reading the whole table, and an error will be reported when reading the specified sheet name]
Question 102: sequence traversal of binary tree
What is message queuing?
云加速,帮助您有效解决攻击问题!
Mysql-centos7 install MySQL through yum
zabbix_ Get test database failed
SAP ABAP BDC (batch data communication) -018
Sidecar mode