Closed freevryheid closed 1 year ago
Thanks for the library, got a question:
Perhaps I'm misunderstanding the concept of basename - the following returns a basename of 'my' with length 2 - I was expecting a null string with length 0.
#include <cwalk.h> #include <stdio.h> #include <stddef.h> #include <stdlib.h> int main(int argc, char *argv[]) { const·char·*basename; size_t length; cwk_path_set_style(CWK_STYLE_UNIX); cwk_path_get_basename("/my/", &basename, &length); printf("The basename is: '%.*s'", length, basename); return EXIT_SUCCESS; }
Hi @freevryheid
Thanks for asking. The basename is the last segment of the path. Maybe you are looking for cwk_path_get_dirname instead?
Got it - thanks!
Thanks for the library, got a question:
Perhaps I'm misunderstanding the concept of basename - the following returns a basename of 'my' with length 2 - I was expecting a null string with length 0.