MS vc library that apart between directory path

What function in MS vc library (Visual Studio environment) that apart between path of the directory containing a filename and filename itself

1
2
3
4
5
6
7
8
9
10
11
12
13
14
//...sort of :
const char *path = TEXT("foo\bar\baz.c");
char *dir, *file ;

fun_Dir_File( path, dir, file)

cout << dir <<"\n\n";
cout << file <<"\n";

//...

foo\bar\

baz.c
Last edited on
Raw pointers? Nuts!

How about a different question:
How to get substrings from a string with C++?

One example:
http://www.cplusplus.com/reference/string/string/find_last_of/


Do notice that backslash '\' is a special character. I've got the impression that one can use forward slash '/' as directory separator in Windows. If not, the hell with it!


Furthermore, if you really work with paths and not just random text, then use C++17's std::filesystem library.
iirc
std::filesystem::parent_path === dirname()
std::filesystem::filename === basename()
yes, newer windows allow / or \ either.
DOS and Windows always recognised / internally. But the Shell (cmd.exe or GUI) only accepts \.
What I was trying to say is: cmd takes / now. I don't know when that changed, but it works in win 10. At one point, it didnt.
Some of the built-in commands are still awful at accepting /,
e.g. type ./file.txt
Last edited on
Topic archived. No new replies allowed.