0
Eai guys. I need to do an e-mail check with these features.
Email must have: 3 more characters; an arroba sign (@); another 3 characters or more; followed by a endpoint sign (.); and a set of at least 2 characters.
What I did was that, but he’s skipping a few conditions.
main(){
int x;
char email[50]={"[email protected]"};
int arroba,ponto,passa,maior,c_P,c_S,i;
int tam=strlen(email);
char teste='.';
for (i = 0; i < tam; i++) {
if(email[i] > 3){
maior=1;
}if(email[i] == '@'){
arroba=1;
}if(arroba == 1 && email[i] >= 3){
c_P=1;
}if(email[i]=='.'){
ponto=1;
}if(ponto=1 && email[i] >=2){
c_S=1;
}
if(maior==1 && arroba == 1 && c_P==1 && c_S ==1){
passa=1;
}else{
passa=0;
}
}
if(passa==1){
printf("Valido");
}else{
printf("Invalido");
}
}
This is for some class or really need an efficient email validator?
– Rogério Dec
yes it’s part of a job I need to deliver. I can’t use pointers or functions that do that in the case. If you know a better way to do thank you.
– Igor Vargas
only c or can c++?
– Rogério Dec
need in C. But in case you only know in c++ I can get some idea of how to do
– Igor Vargas