c++ 找出char数组里面的汉字

// ConsoleApplication4.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "string"
#include <Windows.h>
#include <iostream>

using namespace std;


int main()
{
	string str;
	char arr[] = "中国woaini江315苏";
	int i = 0;
	while(arr[i])
	{
		if (arr[i]>>7)
		{
			str.push_back(arr[i]);
		}
		i++;
	}
	setlocale(LC_ALL, "chinese-simplified");
	cout << str << endl;
	system("pause");
    return 0;
}

猜你喜欢

转载自blog.csdn.net/dxm809/article/details/113734104