為什么要按兩次空格才能出現(xiàn)結(jié)果呀
#include<iostream>
#include<string>
using namespace std;
int main()
{
string name;
cout<< "Please input your name :";
getline(cin, name);
if(name.empty())
{
cout << "Input is null..."<<endl;
system("pause");
return 0;
}
if(name =="imooc")
{
cout<<"you are a administrator"<<endl;
}
cout<<"hello " + name<<endl;
cout<<"your name length is : "<<name.size()<<endl;
cout<<"your first letter is : "<<name[0]<<endl;
system("pause");
return 0;
}
2018-03-09
system("pause"); ?的作用是暫停,按任意鍵繼續(xù)。有的編譯器在編譯的時(shí)候自帶暫停,所以需要按兩次,但exe文件如果沒有這句話,運(yùn)行后就會(huì)直接退出了