0
int main() {
    string getEmail;

    string email, firstName, lastName;
    string dot = ".";
    cout << "What is your email?" << endl;
    getline(cin, email);
    firstName = "";
    lastName = "";
    string::size_type i;
      for (i = 0; !isspace(email.at(i)); i++)
        firstName = firstName + email.at(i);

    for (i = i + 1; i < email.length(); i++)
          lastName = lastName + email[i];
    

    cout << lastName << ", " << firstName << endl;
    return 0;
}

This program separates my text when there is a space and switches its position e.i: I am becomes am, I. Instead of space, how can I do the same if the string hold a specific letter. e.i I!am becomes am,I

0 Answers0