linux int to string 方法
最近从windows 移植程序的时候发现to_string()函数在linux 中不能用,网上找了几种方法,觉得使用stringstream对象来实现类型转化比较好一点。
你只需在你工程中加入下面的to_sting()函数,就不需要修改你原程序了。(这篇只是本人移植工程时的心得,高手绕过!)
/*
* to_string.cpp
* Created on: 2014年9月11日
* Author: tursunjan
* linux int to string
*/
#include<iostream>
#include<sstream>
using namespace std;
string to_string(int a)
{
ostringstream ostr;
ostr << a;
string astr = ostr.str();
//cout << astr <<endl;
return astr ;
}
int main()
{
int testNum=;
cout<<to_string(testNum)<<endl;
return ;
}
linux int to string 方法的更多相关文章
- C#部分---arraylist集合、arraylist集合中的object数据转换成int类string类等;间隔时间的表示方法;
ArrayList和Array的区别: 相同点:1.两者都实现了IList.ICollection.IEnumerable接口: 2.两者都可以使用证书索引访问集合中的元素,包括读取和赋值 ...
- java中Object转换成int或String类型方法
转载: http://www.cnblogs.com/1020182600HENG/p/6137206.html Object obj = getObject(); if(obj instanceof ...
- PDO 查询mysql返回字段int变为String型解决方法
PDO 查询mysql返回字段int变为String型解决方法使用PDO查询mysql数据库时,执行prepare,execute后,返回的字段数据全都变为字符型. 例如id在数据库中是Int的,查询 ...
- 编写Java应用程序。首先,定义描述学生的类——Student,包括学号(int)、 姓名(String)、年龄(int)等属性;二个方法:Student(int stuNo,String name,int age) 用于对对象的初始化,outPut()用于输出学生信息。其次,再定义一个主类—— TestClass,在主类的main方法中创建多个Student类的对象,使用这些对象来测 试Stud
package zuoye; public class student { int age; String name; int stuNO; void outPut() { System.out.pr ...
- C++ Daily 《4》----一个简单的 int to string 的方法
经常会在项目中用到 int to string, 之前一般用C语言的 sprintf, 发现C++ 中的 ostringstream 可以轻松完成这个任务. #include <iostream ...
- 5.编写Java应用程序。首先,定义描述学生的类——Student,包括学号(int)、 姓名(String)、年龄(int)等属性;二个方法:Student(int stuNo,String name,int age) 用于对对象的初始化,outPut()用于输出学生信息。其次,再定义一个主类—— TestClass,在主类的main方法中创建多个Student类的对象,使用这些对象来测 试St
Student类: package com.bao; public class Student { int stuNo;String name,sex;int age,weight; Student( ...
- 截取linux文件存储路径方法
1.截取linux文件存储路径方法 package com.tydic.eshop.action.freemarker; public class dddd { public static void ...
- 微信录音文件上传到服务器以及amr转化成MP3格式,linux上转换简单方法
微信公众号音频接口开发 根据业务需求,我们可能需要将微信录音保存到服务器,而通过微信上传语音接口上传到微信服务器的语音文件的有效期只有3天,所以需要将文件下载到我们自己的服务器. 上传语音接口 wx. ...
- C++ int转string(stringstream可转更多类型)
一.使用atoi 说明: itoa( int value, char *string, int radix ); 第一个参数:你要转化的int; 第二个 ...
随机推荐
- Delphi XE7 开发ActiveX 及在IntraWeb下调试
最近学习DelphiXE7下Intraweb开发,Intraweb完全服务器端运行使得FastReport报表系统无法在客户端运行,当然网上也有一大堆解决方案,例如导出到PDF后,给出连接,让客户点击 ...
- JSP九大隐式对象
JSP九大隐式对象 request HttpServletRequest response HttpServletResponse session HttpSession application Se ...
- Android监听事件
ListView事件监听: setOnItemSelectedListener 鼠标滚动时触发 setOnItemClickListener 点击时触发 EditText事件监听: setOnKeyL ...
- Linux/CentOS下的CST和UTC时间的区别以及不一致的解决方法
今天被我遇到了,相差八小时,,,tzselect过了都不行,还得用ntupdate核一下. 网上找的,备不时之需要. ~~~~~~~~~~~~~~~~ 1.在linux中,用date查看时间的时候显示 ...
- Basefragment的封装使用
1.前言 封装作为面向对象的三大特性之一,在我们平时的coding过程用的那是非常的多的.大多数时候,我们可以根据封装情况评判代码的质量水平. 本文主要讲解的是fragment的封装.大体上,在项目的 ...
- git “bad index file sha1 signature fatal: index file corrupt”错误
在执行commit或revert等操作时,提示“bad index file sha1 signature fatal: index file corrupt”错误,导致操作失败.这是由于git的in ...
- B450配置
电脑型号 联想 B450 笔记本电脑 (扫描时间:2015?5?7?操作系统 Windows 7 旗舰版 32位 SP1 ( DirectX 11 ) 处理器 英特尔 酷睿2 双核 T9800 @ ...
- 【转】listView中,checkBox的显示和隐藏
原文网址:http://www.cnblogs.com/vicma/p/3460500.html 在listView中,每个item都有一个ChexBox,当显示的时候在listView外面设置一个按 ...
- 2014-08-01 ASP.NET中对SQLite数据库的操作——ADO.NET
今天是在吾索实习的第18天.我主要学习了如何在ASP.NET中对SQLite数据库的操作,其基本操作如下: 添加引用System.Data.SQLite.dll(PS:在网页里面任意找到适合的.NET ...
- Red Gate - SQL Source Control实现对SQL SERVER 的源代码控制
原文地址:http://bbs.csdn.net/topics/350165431 SQL Server 一直没有一款很好的源码控制器,之前自己曾尝试自己写一个,将所有的 脚本 自动生成到某一目录下, ...