请问如果是汉语名字,如何修改使其输出名字的首个汉字?(如下)
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{ string user_name;
cout << "Please input user_name:" ;
getline(cin,user_name);
if(user_name.empty())
{
cout<<"Your input is null!"<<endl;
return 0;
}
cout<<"Hello "+user_name<<endl;
if(user_name=="imooc")
{
cout<<"You are a sdministrator"<<endl;
}
cout<<"Your name length is:"<<user_name.size()<<endl;
cout<<"Your name first letter is :"<<user_name[0]<<endl;// 如果输入汉字,没办法输出第一个首字母。第一个汉字怎么输出?
system("pause");
return 0;
}