Visual c++ 如何使用平台::字符串迭代器。C++/CX
这是从win 8.1应用程序中读取字符串并尝试使用迭代器的处理程序。 我使用VS2013Visual c++ 如何使用平台::字符串迭代器。C++/CX,visual-c++,Visual C++,这是从win 8.1应用程序中读取字符串并尝试使用迭代器的处理程序。 我使用VS2013 void MainPage::Button_Click_1(Object^ sender, RoutedEventArgs^ e) { char16 c; int cont = 0; auto beg1 = begin(_number1->Text); auto beg2 = _number1->Text->Begin(); auto e
void MainPage::Button_Click_1(Object^ sender, RoutedEventArgs^ e)
{
char16 c;
int cont = 0;
auto beg1 = begin(_number1->Text);
auto beg2 = _number1->Text->Begin();
auto end1 = end(_number1->Text);
auto end2 = _number1->Text->End();
int len1 = end1 - beg1;
int len2 = end2 - beg2;
int len3 = _number1->Text->Length();
for (const char16 *it = begin(_number1->Text); it != end(_number1->Text); it++)
{
c = *it;
cont++;
}
}
使用调试器发现迭代器beg1和beg2不相等;for循环有时不会停止,因为“end(\u number1->Text)”的计算不正确
有人能帮我吗?
错误在哪里
多谢各位 Platform::String是一种互操作类型,您应该尽快将其转换为std::wstring。当然,您在迭代wstring时不会遇到什么麻烦。谢谢。但是为什么会有Begin()和End()方法呢?