code.cpp 476 B

1234567891011121314151617
  1. /* Write a function that maps files to their extension names.
  2. */
  3. std::vector<std::string> getExtension(std::vector<std::string> arr) {
  4. std::vector<std::string> extensions;
  5. for(int i=0;i<arr.size();i++){
  6. // create a std::string and assign the element value to the variable
  7. std::string tempstring = arr[i];
  8. for(int j=tempstring.size();j>0;j--){
  9. if(tempstring[j]== '.'){
  10. extensions.push_back(tempstring.substr(j+1));
  11. break;
  12. }
  13. }
  14. }
  15. return extensions;
  16. }