字符串和数字转换
来源:互联网 发布:凯聪智云软件下载 编辑:程序博客网 时间:2024/05/01 09:17
#include "stdafx.h"
#include "sstream"
using namespace std;
#define Log(fmt,...) \
printf(("%s<%s:%d>"),__FILE__,__FUNCTION__,__LINE__);\
printf(fmt, __VA_ARGS__);\
printf("\r\n");
template<class T> T StringToNum(std::string & _str)
{
T t = T();
std::istringstream iss(_str);
iss>>std::dec>>t;
return t;
}
template<class T> std::string NumToString(T _t)
{
std::ostringstream oss;
oss<<std::dec<<_t;
return oss.str();
}
int _tmain(int argc, _TCHAR* argv[])
{
// 字符串转换成数字
std::string strValue("123");
int iTest = StringToNum<int>(strValue);
// 数字转换成字符串
std::string str = NumToString("12.5");
Log(str.c_str());
return 0;
}
0 0
- 字符串和数字转换
- 字节和数字,字符串转换
- php 数字和字符串转换
- 字符串和数字相互转换
- 数字和字符串的转换
- 字符串和数字相互转换
- 字符串和数字的转换
- 字符串和数字相互转换
- 数字和字符串的转换
- 数字和字符串的转换(转)
- JavaScript数字和字符串转换小结
- vc中数字和字符串的转换
- 字符串和数字的相互转换
- VC 字符串和数字转换函数
- 字符串IP和数字转换的杂谈
- 数字和字符串转换的函数
- JavaScript数字和字符串转换小结(转)
- 字符串IP和数字转换的杂谈
- hdu 5057 Argestes and Sequence
- 静态类型检查与继承
- HDU 1098解题报告
- 在VM中安装Android4.4连接小米手机 之 安装小米手环APP
- ZOJ——3464 Rugby Football
- 字符串和数字转换
- H265 SAO 技术
- 程序员求职之道(《程序员面试笔试宝典》)
- 【Unity3D】 KeyCode 键码
- poj - 1170 - Shopping Offers(状态压缩dp)
- 在VM中安装Android4.4连接小米手环 之 设置蓝牙
- poj1654--Area(几何求面积)
- .net 获取odbc驱动列表
- Attribute value request.getParameter("itemID") is quoted with " which must be escaped when used with