您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

在C/C++中,wcstoll()函数的翻译是什么?

2025/8/11 19:17:37发布29次查看
wcstoll()函数用于将宽字符串转换为长整型。它将指针设置为指向最后一个字符之后的第一个字符。语法如下。
long long wcstoll(const wchar_t* str, wchar_t** str_end, int base)
该函数需要三个参数。这些参数如下所示 -
str: 这是宽字符串的开头。str_end :函数将str_end设置为最后一个有效字符之后的下一个字符(如果有任何字符),否则为null。base:这指定基地。基值可以是 (0, 2, 3, …, 35, 36)该函数返回转换后的 long long 整数。当字符指向null时,返回0。
示例#include <iostream>using namespace std;main() { //define two wide character string wchar_t string1[] = l"777helloworld"; wchar_t string2[] = l"565hello"; wchar_t* end; //the end pointer int base = 10; int value; value = wcstoll(string1, &end, base); wcout << "the string value = " << string1 << "\n"; wcout << "long long int value = " << value << "\n"; wcout << "end string = " << end << "\n"; //remaining string after long long integer value = wcstoll(string2, &end, base); wcout << "\nthe string value = " << string2 << "\n"; wcout << "long long int value = " << value << "\n"; wcout << "end string = " << end; //remaining string after long long integer}
输出the string value = 777helloworldlong long int value = 777end string = helloworldthe string value = 565hellolong long int value = 565end string = hello
现在让我们看看具有不同基值的示例。这里的基数是16。通过获取给定基数的字符串,它将以十进制格式打印。
示例#include <iostream>using namespace std;main() { //define two wide character string wchar_t string1[] = l"5ehelloworld"; wchar_t string2[] = l"125hello"; wchar_t* end; //the end pointer int base = 16; int value; value = wcstoll(string1, &end, base); wcout << "the string value = " << string1 << "\n"; wcout << "long long int value = " << value << "\n"; wcout << "end string = " << end << "\n"; //remaining string after long long integer value = wcstoll(string2, &end, base); wcout << "\nthe string value = " << string2 << "\n"; wcout << "long long int value = " << value << "\n"; wcout << "end string = " << end; //remaining string after long long integer}
输出the string value = 5ehelloworldlong long int value = 94end string = helloworldthe string value = 125hellolong long int value = 293end string = hello
这里的字符串包含 5e,因此其值为十进制 94,第二个字符串包含 125。这是十进制的 293。
以上就是在c/c++中,wcstoll()函数的翻译是什么?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product