Simple - just determine the length of the string stored in szFileName and search backwards until you fine the '.' then compare that to the extension you are looking for. In other words use you brain, not the internet, to solve the problem.
The following old style C-code should do the trick:
int HasExtension(const char* szFileName, const char* szExt)
{
if ('\0' != *szFileName)
{
int i;
for( i = strlen(szFileName) - 1; i > 0; --i)
{
if ('.' == szFileName[i])
break;
}
}
return (0 == strcmp(szFileName + i, szExt));
}
This is not the only way to do this in C, but it will get the job done.
See if you can accomplish the same task with a while loop.
Do your research. The modern standard C library may have newer functions that will do this type of thing for you. A good C programmer should have the ability to write the standard library from scratch without using the internet.
After seeing Shao's answer I thought I would throw this improvement in. Please note that this has no built in protection against programmer error.
int StringEndsWith(const char* szFileName, const char* szExt)
{
return (strcmp(&szFileName[strlen(szFileName) - strlen(szExt), szExt) == 0);
}