I made a email checking function but after i get the message: Email accepted it seems to crash 3 times ( the program) what am i doing wrong?
Code:
std::string GetValidEmail ()
{
std::string email;
std::cout <<"Your Email address:";
std::getline (std::cin,email);
std::string::size_type checkPoint = email.find( ".", 0 );
std::string::size_type checkAt = email.find( "@", 0 );
while ( checkPoint == std::string::npos || checkPoint == std::string::npos || email.length() >= 50)
{
std::cout <<"Your email is either Too long(max 50 chars) or Invalid.\n"
<<"Please input an shorter or valid email adress." << std::endl;
std::getline (std::cin,email);
checkPoint = email.find( ".", 0 );
checkAt = email.find( "@", 0 );
}
std::cout <<"Email Accepted" << std::endl;
}
and another question : how can i make my email checking function even better? maby implement some kind of list of known emailaddreshosters?
and if u might need it lol:
Code:
int main ()
{
std::string kaka;
kaka = GetValidEmail ();
std::cout << kaka << std::endl;
}