Free for PREMIUM members
Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!
Learn how Concerto can help you.
// Function to validate an e-mail address with the extra rules
// that user name part
// must begin with a letter,
// must end with a letter or numeral,
// may only consist of letters, numerals, dashes and dots and
// may not have consequtive dashes or dots.
// Note -. and .- are illegal consequtive dash/dots.
// Original code found on etutorials.org
// Modified to meet the needs of another member at Experts Exchange.
// Last modification: Hugh McCurdy 21-Aug-2012
#define TRUE (1)
#define FALSE (0)
// return TRUE if and only if c is a period or a dash.
int isdotdash ( const char c )
switch ( c )
} // isdotdash
int spc_email_isvalid(const char *address)
int count = 0;
const char *c, *domain;
static char *rfc822_specials = "()<>@,;:\\\"";
c = address;
// First character must be a letter.
if ( ! isalpha ( *c ))
for ( c = address + 1; *c && *c != '@'; c++ )
// dot/dash check. Consequtive illegal. (--, .., .- and -. illegal)
if ( isdotdash ( *c ))
if ( isdotdash ( *( c - 1 )))
// if not a dot/dash then only alphanumeric characters are legal.
else if ( ! isalnum ( *c ))
} // for
// Make sure the current character is an @
if ( *c != '@' )
// Now make sure the character before the @ is a alphanumeric.
if ( ! isalnum ( *(c - 1 )))
/* next we validate the domain portion (name@domain) */
if (!*(domain = ++c)) return 0;
if (*c == '.')
if (c == domain || *(c - 1) == '.') return 0;
if (*c <= ' ' || *c >= 127) return 0;
if (strchr(rfc822_specials, *c)) return 0;
} while (*++c);
return (count >= 1);
} // spc_email_isvalid()
// main() only used for testing.
int main ( void )
static const char *list =
for ( i = 0; *list [ i ]; i++ )
printf ( "%s %s\n", spc_email_isvalid ( list[i] ) ? "PASS" : "FAIL", list[i] );
} // main()
Open in new window
Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.