How can I convert a string to an unsigned long long int?
如何将字符串转换为unsigned long long int?
The problem is that if I use strtol
that returns a long int, but I need to convert a string longer than that.
问题是,如果我使用strtol返回一个long int,但我需要转换一个比这更长的字符串。
4 个解决方案
#1
5
There is strtoull()
which sounds like a very good match:
有strtoull()听起来像一个非常好的匹配:
unsigned long long int strtoull(const char *nptr, char **endptr, int base);
No idea why you didn't find it.
不知道为什么你没找到它。
#2
0
You can use strtoll
for long long
type.
你可以使用strtoll长型。
You can also use sscanf
with %ll
format specifier to convert to long long
.
您还可以使用带有%ll格式说明符的sscanf转换为long long。
Also, you can write your own implementation if it does not fulfill your purpose.
此外,如果它不能满足您的目的,您可以编写自己的实现。
#3
0
if only there was a standard library function that SCANned a Formated String... sscanf maybe
如果只有一个标准库函数可以扫描一个Formated String ... sscanf
#1
5
There is strtoull()
which sounds like a very good match:
有strtoull()听起来像一个非常好的匹配:
unsigned long long int strtoull(const char *nptr, char **endptr, int base);
No idea why you didn't find it.
不知道为什么你没找到它。
#2
0
You can use strtoll
for long long
type.
你可以使用strtoll长型。
You can also use sscanf
with %ll
format specifier to convert to long long
.
您还可以使用带有%ll格式说明符的sscanf转换为long long。
Also, you can write your own implementation if it does not fulfill your purpose.
此外,如果它不能满足您的目的,您可以编写自己的实现。
#3
0
if only there was a standard library function that SCANned a Formated String... sscanf maybe
如果只有一个标准库函数可以扫描一个Formated String ... sscanf