check is mail vaild
#2

I'd rather use sscanf than editing it, especially since it doesn't even check for valid domains at all (so editing the code to check for specific domains would require more work than just solving it in a simpler way).

I'd just use sscanf to split the mail into 2 parts:

- email
- domain (gmail.com, yahoo.us, etc)

Код:
new email[65], domain[15];
sscanf(string, "s[65]'@'s[15]'", email, domain);
Now you can check domain for the desired content, eg. using strcmp.

Note that this doesn't ensure actually valid email addresses. But this shouldn't even matter because it'll be the user's fault if they cannot properly enter their email address. Or putting in fake emails (which is what everyone does if they don't want to give their real email anyway - so there's not really a point in a 100% email validation).
So if you use the email for activation purposes you can just send it to whatever the user typed it, it just won't get sent if it's wrong.

You could also use both if you really want the emails to be correct in format, by first using your function and then checking the domain only.
Reply


Messages In This Thread
check is mail vaild - by PoniStar - 16.11.2018, 04:37
Re: check is mail vaild - by NaS - 16.11.2018, 05:23
Re: check is mail vaild - by PoniStar - 16.11.2018, 06:06

Forum Jump:


Users browsing this thread: 2 Guest(s)