Thursday, October 16, 2014

Email Address Checker

In this article I would like to share with you a sample program that will check whether the email address that is being given by the user is valid or invalid using C++ as my programming language.

If you like my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com

Thank you very much.


Sample Output of Our Program


Program Listing

#include <iostream>

using namespace std;

bool check1(char* Address,bool Logic)


    {
    int bilA=0;
    for(int Loop1=0; Loop1<255; Loop1++)


        {
        if(Address[Loop1]=='@')


            {
            bilA++;
            if(Address[Loop1-1]==' '||Address[Loop1+1]==' ')


                {
                Logic = false;
                cout << "\n\a\t\tNo empty space before or after @!";
                break;
            }
        }
    }
    if (bilA<1||bilA>1)


        {
        Logic = false;
        cout << endl << "\a\t\tRecheck your number of @!" << endl;
    }
    return Logic;
}
bool check2(char* Address,bool Logic)


    {
    int bilDOT = 0;
   for(int Loop2=0; Loop2<255; Loop2++)


        {
        if(Address[Loop2]=='.')


            {
            bilDOT++;
            if(Address[Loop2-1]==' '||Address[Loop2+1]==' ')


                {
                Logic = false;
                cout << "\n\a\t\tNo empty space before or after dot!";
                break;
            }
        }
    }
    if (bilDOT<1||bilDOT>1)


        {
        Logic = false;
        cout << endl << "\a\t\tRecheck your number of dot!" << endl;
    }
    return Logic;
}


int main()


    {
    int Characters = 0;
    int Select;
    char Address[255] = "";


        bool Logic = true;

             cout << "\n\n\t\t  EMAIL ADDRESS CHECKER VERSION 1.0";
             cout << "\n\n\t  Created By: Mr. Jake Rodriguez Pomperada,MAED-IT";
             cout << "\n\n";
             cout << "\n\tEnter Your Email Address: ";
            cin.ignore();
            cin.get(Address,255,'\n');
            cin.ignore();
            Characters = strlen(Address);
            if(Logic)


                {
                Logic = check1(Address,Logic);
                Logic = check2(Address,Logic);
            }
            if(Address[0]=='@'||Address[Characters-1]=='@')


                {
                cout << endl << "\t\t\a@ misplaced at ends!" << endl;
                Logic = false;
            }
            if(Logic)


                {
                cout << "\n\t\t[ YOUR EMAIL IS VALID ]";

            }
            else


                {
                cout << "\n\t\t[ INVALID EMAIL!! ]";

            }

 cout << "\n\n\n";
 system("pause");

}

No comments:

Post a Comment