For the book club sign-up, the username is the part of the email before @: [email protected] gives amy. Write user_name(email); if there is no @, return the whole thing as it is.
user_name("bao")→'bao'string user_name(const string &email)#include <string>
using namespace std;
string user_name(const string &email) {
auto at = email.find('@');
if (at == string::npos) {
// your code here: no @ found, so return the whole email
}
// your code here: return the part before the @
return "";
}
Run tries the examples. When they look right, Submit.