我这样写为什么也能通过还能得出结果,老师为什么说这里特殊情况一定要用getline函数呢?
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
cout << "请输入姓名:" << endl;
string s1;
cin >> s1 ;
if (s1.empty() == 1)
{
cout << "您输入为空" << endl;
}
cout << "hello " + s1+"!"<<endl;
cout << "您的姓名长度为:" << s1.size() << endl;
cout << "您的姓名首字母为:" << s1[0] << endl;
if (s1=="imooc")
{
cout << "您是管理员" << endl;
}
system("pause");
return 0;
}