為何輸入姓名后要按兩下回車才有結(jié)果
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
string name;
cout<<"請輸入姓名:";
getline(cin,name);
if(name.empty())
{
cout<<"輸入為空"<<endl;
system("pause");
return 0;
}
if(name == "imooc")
{
cout<<"you are a administrator"<<endl;
}
cout<<"hello "+ name<<endl;
cout<<"名字首字母是:"<<name[0]<<endl;
cout<<"名字的長度是:"<<name.size()<<endl;
system("pause");
return 0;
}
2016-07-08
為何結(jié)果后面“請按任意鍵繼續(xù)”回車后又會有“press any key to continue?”?