Saturday, 25 January 2014

   How TO check if the EMAIL is correct or Not ---- C++
by ComputerTipsAndTricks....
https://www.facebook.com/pages/Computer-Tips-and-Tricks/645330865508544?ref=hl
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
void com(char A[]);
main()
{cout<<"Email : ";
 char email[40];
 gets(email);
 com(email);

  }

 void com(char email[])
 {
 char emailcom[5]=".com";
 char emailco[7]=".co.in";
  int com=0;                                             // 64 ascii for @
  int co=0;
  int l=strlen(email);
  int x=0;
  l=l-4;
  int i=0;
  int k=0;
  int at=0;
  while(email[x]!='\0')
  {if(email[x]=='@')
at++;
x++;
}

  while(email[l]!='\0'&&i<4)
  {if(email[l]==emailcom[i])
k++;
l++;
i++;
  }
  l=strlen(email);
  l=l-6;
  i=0;
  int t=0;
  while(email[l]!='\0'&&i<6)
  {if(email[l]==emailco[i])
t++;
l++;
i++;

}

 if((k==4||t==6)&&at==1)
 cout<<"";
 else
 cout<<"Incorrect Email Provided ";


 }

No comments:

Post a Comment