I'm trying to create a method that can get the extension of a file. I found multiple alternatives and this one was my solution:
const char *getExt(const char *filename) {
const char *ext = strrchr(filename, '.');
if(!ext || ext == filename){
return "No Extension";
}else{
return ext + 1;
}
}
Now, the problem is with the extension .tar.gz
.
How can I select this kind of extension too without messing every other extension with only one dot (.
)?