当前位置:网站首页>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;
边栏推荐
- Interview questions and salary and welfare of Shanghai byte
- 【已解决】记一次EasyExcel的报错【读取xls文件时全表读不报错,指定sheet名读取报错】
- Nodejs get client IP
- 【FPGA教程案例14】基于vivado核的FIR滤波器设计与实现
- Get the way to optimize the one-stop worktable of customer service
- Forkjoin is the most comprehensive and detailed explanation (from principle design to use diagram)
- nVisual网络可视化
- STM32按键状态机2——状态简化与增加长按功能
- cf:C. Column Swapping【排序 + 模拟】
- Things about data storage 2
猜你喜欢
Question 102: sequence traversal of binary tree
深度聚类:将深度表示学习和聚类联合优化
Nvisual network visualization
Introduction to the extension implementation of SAP Spartacus checkout process
C nullable type
Why does the data center need a set of infrastructure visual management system
PowerPivot——DAX(函数)
Interview questions and salary and welfare of Shanghai byte
Bbox regression loss function in target detection -l2, smooth L1, IOU, giou, Diou, ciou, focal eiou, alpha IOU, Siou
VScode进行代码补全
随机推荐
深度聚类:将深度表示学习和聚类联合优化
Say sqlyog deceived me!
win配置pm2开机自启node项目
毕业之后才知道的——知网查重原理以及降重举例
牙齿干细胞的存储问题(未完待续)
cf:C. Column Swapping【排序 + 模擬】
Check Point:企业部署零信任网络(ZTNA)的核心要素
Pytorch builds neural network to predict temperature
MFC BMP sets the resolution of bitmap, DPI is 600 points, and gdiplus generates labels
Flask 1.1.4 werkzeug1.0.1 analyse du code source: processus de démarrage
Distributed global ID generation scheme
Nodejs get client IP
mac版php装xdebug环境(m1版)
Opensergo is about to release v1alpha1, which will enrich the service governance capabilities of the full link heterogeneous architecture
Realize GDB remote debugging function between different network segments
[daily training -- Tencent selected 50] 235 Nearest common ancestor of binary search tree
[cloud native] what is the microservice architecture?
CTFshow--常用姿势
【FPGA教程案例14】基于vivado核的FIR滤波器设计与实现
Hcip eighth operation