调用string的函数
代码如下
string str = "[email protected]";
string email_type;
size_t res1 = str.find('@');
size_t res2 = str.find('.');
email_type = str.substr(res1+1, res2-res1-1);
cout <<"邮箱类型:"<< email_type << "邮箱"<<endl;
关键点在于寻找@和.的位置,然后使用substr进行截取字符串