請問如果是漢語名字,如何修改使其輸出名字的首個漢字?(如下)
#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;
}
2017-03-30
輸出的時候這樣來
2018-05-01
6666666666666666666
2018-01-26
一個漢字由兩個ASCII碼組成
2017-03-30
好像實現不了
2017-03-30
自動判斷中文和英文的代碼
2017-03-30
但是如果你要自動判斷輸入為中文和英文的話,還得改別的東西