Posted By

tandouri on 08/21/09


Tagged

get file path name find


Versions (?)

get filename from a filepath


 / Published in: C
 

for cmdparsing

  1. /* ------------------------------------------------------------------------------- *\
  2. | # get_filename_from_path : searches a given filepath for its name |
  3. | @param : char* to the existing filepath |
  4. | @return : char* to the found filename |
  5. \* ------------------------------------------------------------------------------- */
  6. char* get_filename_from_path(char* filepath) {
  7.  
  8. char *filename = (char*)calloc(1, sizeof(SIZE_FILENAME));
  9. filename = (strrchr(filepath, '/'))+1;
  10. printf(" found filename: %s \n", filename);
  11.  
  12. return filename;
  13.  
  14. }

Report this snippet  

You need to login to post a comment.