C++ : Convert fileparts Matlab Code

If you use Matlab, we can get pathname, filename and extension from input full string path. How if we want extract dirname, filename and extension in C++ ? I want to get pathdir, filename and extension from input string. I have created a simple code how to extract path, filename and extension from fullpath string in C++. Please check below code :

Save code to fileparts.cpp. Compile code using command :

Below is result from running code above :

Using above code, we can extract dirname, filename and extension from input of string using C++.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.