You can look for the last .
with strrchr
and then compare for the extension with strcmp
int found = 0;
char *p = strrchr(argv[1], '.');
if (p)
found = strcmp(p, ".jpeg") == 0;
Alternatively, take the length of the extension off the end of the string and compare that
const char *ext = ".jpeg";
size_t xlen = strlen(ext);
size_t slen = strlen(argv[1]);
int found = strcmp(argv[1] + slen - xlen, ext) == 0;
This will also work in cases like .tar.gz
.