get_last_segment()

get_last_segment()#

Extracts the last segment from a given file path by locating the last occurrence of the ‘/’ character and returning the substring that follows it.

Prototype

char *get_last_segment(char *path);

Parameters

Key

Type

Description

path

char *

The file path from which the last segment will be extracted.


Return Value

A pointer to the last segment of the path. If no ‘/’ is found, returns the original path.

Notes

The function does not modify the input string.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples