On Mon, 5 Oct 1998, Ibrahim F Haddad wrote:
> I need to check whether the file is of extension xyz (i.e. name.xyz).
> I determine the lenght of the fileName (strlen(fileName)).
> How can i then check if the last 4 characters are .xyz in a neat
> way. Cause if they're not i will return a warning message.
register int i;
for (i = strlen(filename)-1; i > 0; --i)
if ( filename[i] == '.' ) break;
if (i == 0) throw NoExtensionError;
if (strcmp( &filename[i], ".xyz" ) == 0 ) return OK;
throw ExtensionMismatchError;
return ERROR;