##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::experimental::filesystem::path::stem

From cppreference.com
< cpp‎ | experimental‎ | fs‎ | path

path stem() const; |  | (filesystem TS)

Returns the filename identified by the path stripped of its extension.

If filename() is not equal to `.` or `..`, then returns the substring between its beginning and the last `.` character, if present. The `.` character is not included into the return value.

### [edit] Parameters

(none)

### [edit] Return value

The stem of the filename identified by the path.

### [edit] Exceptions

(none)

### [edit] Example

Run this code

    #include <filesystem>
    #include <iostream>

    int main()
    {
        std::cout << std::fs::path("/foo/bar.txt").stem() << '\n';
        std::cout << std::fs::path("/foo/.bar").stem() << '\n';
        std::cout << std::fs::path("/foo/bar").extension() << '\n';
    }

Output:

    bar

    bar

### [edit] See also

filename | returns the filename path component (public member function) [edit]
extension | returns the file extension path component (public member function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/experimental/fs/path/stem&oldid=68637"