我想從字符串轉換爲uint64_t整數。 stoi
返回一個32位整數,所以它不會在我的情況下工作。還有其他解決方案嗎?C++將字符串轉換爲uint64_t
2
A
回答
6
你嘗試
uint64_t value;
std::istringstream iss("18446744073709551610");
iss >> value;
?
這可能對於過時的標準工作了。
5
如果您使用C++ 11或更高版本,請嘗試std::stoull
。
This post也可能有幫助。因爲其他的問題是關於C.
2
如果你使用升壓我沒有這個標記爲重複的,你可以利用boost::lexical_cast
#include <iostream>
#include <string>
#include <boost-1_61/boost/lexical_cast.hpp> //I've multiple versions of boost installed, so this path may be different for you
int main()
{
using boost::lexical_cast;
using namespace std;
const string s("2424242");
uint64_t num = lexical_cast<uint64_t>(s.c_str());
cout << num << endl;
return 0;
}
相關問題
- 1. C++將SATOSHI(uint64_t)轉換爲BTC(字符串)無浮點/雙
- 2. C++ - 將字符串轉換爲字符
- 3. 如何將無符號轉換爲uint64_t?
- 4. 如何將二進制64位字符串轉換爲C++中的uint64_t?
- 5. 將uint64_t轉換爲uint8_t [8]
- 6. 將uint64_t轉換爲std :: string
- 7. 將字節數組轉換爲uint64_t?
- 8. C#將字符串轉換爲數字
- 9. 如何將Objective-C字符串轉換爲C字符串?
- 10. 將字符串轉換爲位圖c#
- 11. C#將字符串轉換爲uint
- 12. C++將char轉換爲字符串
- 13. C#將Unicode轉換爲字符串
- 14. c#將字符串轉換爲變量
- 15. 將字符串轉換爲日期C++
- 16. 將字符串轉換爲System.guid c#
- 17. 將字符串轉換爲int在C++
- 18. 將字符串轉換爲smtpclient在c#
- 19. 將字符串轉換爲總和C#
- 20. C++ ::將ASCII值轉換爲字符串
- 21. 將C#貨幣轉換爲字符串
- 22. C:將int []轉換爲字符串
- 23. C#,將字符串轉換爲DateTimeOffset
- 24. 將字符串轉換爲long long C?
- 25. 將float轉換爲字符串c
- 26. C#:將字符串轉換爲DBType.AnsiStringFixedLength
- 27. 將double轉換爲字符串C++?
- 28. C:將int轉換爲字符串
- 29. 將C++字符串轉換爲NSString
- 30. 將字符串轉換爲RemoteEndPoint C#sendto
那麼,C++ 11可以被認爲是幾年以來的現行標準。 –
它是* a *標準,但不是**標準。由於工作或遺留代碼或其他原因,仍然有很多人正在使用C++ 03。 – Gambit
當然** **標準是C++ 14? –