Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.0 kB
6
Indexable
Never
void check_email()
{
    int flag1 = 0;//Will change as soon as we find an error
    int flag2 = 0;//Will change once we get to @
    char tav = NULL;
    cout<<"Enter email"<<endl;
    cin>>tav;
    //getchar();
    
    while (tav != ' ')
    {
        if ((tav >= 'a' && tav <= 'z') || (tav >= 'A' && tav <= 'Z') || (tav >= '0' && tav <= '9') || (tav == '@') || (tav == '.') || (tav == '_'))//Check that it was OK

        {
            flag1 = 0;
            flag2 = 1;
            if (flag2 == 1)
            {
                cin>>tav;
                if ((tav >= 'a' && tav <= 'z') || (tav >= 'A' && tav <= 'Z') || (tav >= '0' && tav <= '9') || (tav == '.'))
                {
                    flag1 = 0;
                }
            }
            
        }
        else
        {
            flag1 = 1; //An error was found
            cout<<"Try again : your email address is not correct"<<endl;
            cin>>tav;
            getchar();
        }
    }
    cout<<"Your email address is correct"<<endl;
}