如何从const char *转换为unsigned int C ++ [英] How to convert from const char* to unsigned int c++
本文介绍了如何从const char *转换为unsigned int C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是C ++编程的新手,我一直在尝试从const char *转换为unsigned int,但是没有运气。
我有一个:
I am new in c++ programming and I have been trying to convert from const char* to unsigned int with no luck. I have a:
const char* charVar;
,我需要将其转换为:
unsigned int uintVar;
如何用C ++完成?
谢谢
推荐答案
#include <iostream>
#include <sstream>
const char* value = "1234567";
stringstream strValue;
strValue << value;
unsigned int intValue;
strValue >> intValue;
cout << value << endl;
cout << intValue << endl;
输出:
1234567
1234567
1234567
这篇关于如何从const char *转换为unsigned int C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文