📅  最后修改于: 2020-09-25 09:36:08             🧑  作者: Mango
mbsinit() 函数在
int mbsinit( const mbstate_t* ps);
如果ps
不是空指针,则mbsinit() 函数检查ps是否表示初始转换状态。
mbsinit() 函数返回:
#include
#include
#include
using namespace std;
void test_ps(mbstate_t ps)
{
if (mbsinit(&ps))
cout << "the conversion state is initial conversion state" << endl;
else
cout << "the conversion state is not initial conversion state" << endl;
}
int main()
{
setlocale(LC_ALL, "en_US.utf8");
char str[] = "\u00b5";
mbstate_t ps = mbstate_t();
cout << "Initially after creating ps, ";
test_ps(ps);
mbrlen(str, 1, &ps);
cout << "After performing some task, ";
test_ps(ps);
return 0;
}
运行该程序时,输出为:
Initially after creating ps, the conversion state is initial conversion state
After performing some task, the conversion state is not initial conversion state