小总结:字符串和数字的简单相互转换
2016-07-14 10:23
295 查看
#include <iostream> #include <cstdio> #include <set> #include <vector> #include <map> #include <algorithm> #include <cstring> #include <string> #include <cmath> #include <cctype> using namespace std; int main() { //字符串转换成数字 /* MORE: atoi(), atol(); */ char s1[4] = "123"; double i = atof(s1); printf("%lf\n", i); /* 数字转换成字符串 itoa()函数有3个参数:第一个参数是要转换的数字, 第二个参数是要写入转换结果的目标字符串, 第三个参数是转移数字时所用的基数 MORE: itoa() 将整型值转换为字符串 itoa() 将长整型值转换为字符串 ultoa() 将无符号长整型值转换为字符串 */ int num = 100; char str[25]; itoa(num, str, 10); //这里转换成了十进制 cout << str << endl; cout << str[0] << endl; return 0; }
相关文章推荐
- UVA - 10161 Ant on a Chessboard
- SVN使用
- MYSQL官方下載網址
- 多线程编程 - NSOperationQueue
- 百度地图 使用两条平行线表示路线
- flume安装和avro场景
- UVA - 113 Power of Cryptography
- Twitter使用时API报错Exception in thread "main" Connection refused: connect
- Android中区别Drawable Bitmap Canvas Paint
- 设计响应式网站的注意点
- XNA窗口设置问题
- 【动态规划】XMU 1032 装配线问题
- Jason跳格子
- UVA - 10061 Myacm Triangles
- Java:StringBuilder类的使用
- Android的独白
- PHP X-sendfile实现文件下载
- shell学习-4
- #158 – When to Create a Custom Dependency Property(哪些情况要创建自定义依赖属性)
- Android网络请求框架NoHttp简介