首页
技术博客
登录
6mi
u
盘
搜
搜 索
技术博客
C++数字(int, long ,long long)和字符串之间相互转换
C++数字(int, long ,long long)和字符串之间相互转换
tech
2025-05-17
12
数字转字符串
int
a
=
111
;
stirng s
;
s
=
to_string
(
a
)
;
字符串转数字
//转为int
string s
=
"111"
;
int
a
;
a
=
atoi
(
s
.
c_str
(
)
)
;
//转为long
string s
=
"111"
;
int
a
;
a
=
atol
(
s
.
c_str
(
)
)
;
//转为long long
string s
=
"111"
;
int
a
;
a
=
atoll
(
s
.
c_str
(
)
)
;
转载请注明原文地址:https://tech.qufami.com/read-22117.html
最新回复
(
0
)