Skip to content

Instantly share code, notes, and snippets.

@Yakkie
Last active December 27, 2015 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yakkie/831ee9f0643413c70bcb to your computer and use it in GitHub Desktop.
Save Yakkie/831ee9f0643413c70bcb to your computer and use it in GitHub Desktop.
string allowed_extensions[5] = {".gif", ".jpg", ".png", ".bmp", ".pbb"};
bool checkImage(string file){
string extension = getExtension(file);
for(int i = 0 ; i < 5 ; i ++ )
if(allowed_extensions[i] == extension)
return true;
return false;
}
string getExtension(string file){
int loc = file.find_last_of('.');
if(loc > -1){
return file.substr(loc);
}
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment