练习string,如name.size(),name【n】,俩个“?”之间不可以直接连接,if()为真时执行{}内容。明天继续学习视频,复习
#include<iostream>
#include<stdlib.h>
#include<string>
using namespace std;
#include<stdlib.h>
#include<string>
using namespace std;
int main(void)
{
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:"<<name.size()<<endl;
cout<<"your name first letter is:"<<name[0]<<endl;
{
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:"<<name.size()<<endl;
cout<<"your name first letter is:"<<name[0]<<endl;
system("pause");
return 0;
return 0;
}