将指针字符串转换为整数 [英] convert pointer string to integer

查看:308
本文介绍了将指针字符串转换为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 treePtr-> item.getInvest()转换为包含整数字符串的字符串。这可能吗?

I am trying to convert treePtr->item.getInvest() which contains a string to an integer. Is this possible?

推荐答案

#include <sstream>

// ...

string str(*(treePtr->item.getInvest())); // assuming getInvest() returns ptr
istringstream ss(str);
int the_number;
ss >> the_number;

这篇关于将指针字符串转换为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆