AbigailBurstein (0)

Write a program, containing 3 functions that will ask the user for his or her email address and print out the
● The user's name or ID
● The user's character site type. Display the specific name for all 3-character site types.

I am at lost!

You are viewing a single comment. View All
mwilki7 (943)

You can use find() to search for the '@' and that will give you the index of that symbol. Then use that index to print everything before it or after it.

For example:

string email = "[email protected]"
int at_index = email.find("@");

cout << "Before @: " << email.substr(0, at_index) << endl;
cout << "After  @: " << email.substr(at_index + 1, email.length() - 1) << endl;

you may need to add or subtract 1 to at_index in the substr function, I don't know if substr is "up to index" or "up to and including index".