I have a small piece of C code to pull the email domain from a supplied string, then do a host lookup on it. It seems fairly simple, and works. Could this be simplified further, or made better, though? Thanks for viewing.
struct hostent *host;
int at = 0, ei = 0;
char email_host[MAX_HOSTNAME_LEN];
for ( at = 0; at < strlen(argument); at++ )
{
if (argument[at] == '@' )
{
strcpy(&email_host[ei],&argument[at+1]);
ei++;
}
}
host = gethostbyname(email_host);
if ( !host )
fail = TRUE;
This can be simplified:
to simply: