#include <stdlib.h>
#include <stdio.h>
char
input(char emailInput[100])
{
printf("Enter email:"); // if nothing or wrong email is input repeat//
gets(emailInput);
}
char
checkInputEtDot(char emailInput[100])
{
int i, checkET, checkDot;
checkET = checkDot = 0;
for (i = 0; emailInput[i] != '\0'; i++) {
if (emailInput[i] == '@') // if @ is not entered ask again + ask for @//
checkET = i;
if (emailInput[i] == '.') // if . is not entered ask again + ask for .//
checkDot = i;
}
if (checkET < 1) // seperate function for every validation//
printf("you need @\n"); // function for "@"; if function OK continue//
// if not ask again//
if (checkET < 3)
printf("you need at least 3 charachters before @\n");
if (checkDot < 1)
printf("you need .\n");
if (checkET > 3 && (checkDot - checkET) > 3)
printf("Email is OK");
else
printf("Email is NOT OK");
printf("\n");
}
void
main()
{
char emailInput[100], checkEmailInput;
input(emailInput);
checkInputEtDot(emailInput);
}
for example when input function is not ok, repeat, if ok than check function for "@", if ok function for "." than function for at least 3 characters before "@", if ok, function for 3 characters after "@", if ok , at least 2 characters after ".".
for now that all working, but i need functions so i can upgrade validation process with special charachters.