How to find username from email address in C++

How to find the username from an email address in C++

In this article, I am going to discuss How to find the username from an email address in C++ Language with examples. Please read our previous article, where we discussed How to check if a string is Palindrome or not in C++ with examples.

How to find the username from an email address in C++?

Here, we will write a program to find a username from the given email address. Now let us see the program for this.

Program:
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    string email = "pranayarout88@gmail.com";
    int i = (int) email.find('@');
    string uname = email.substr(0, i);

    cout << "Email is " << email << endl;
    cout << "Username is " << uname << endl;
    return 0;
}
Output:

In the next article, I am going to discuss Functions in C++ with examples. Here, in this article, I try to explain How to find a username from an email address in C++ Language with examples. I hope you enjoy this How to find a username from an email address in C++ with examples article. I would like to have your feedback. Please post your feedback, question, or comments about this article.

Leave a Reply

Your email address will not be published.