You should check the source code of the open-source libraries such as wxWidgets and Qt, and you could also write a function that takes a path to the last directory to create (e.g. "c:\A\B\C") and that splits the path into the several directories (e.g. "c:\A", "C:\A\B" and "C:\A\B\C") and create them one-by-one.
You shoud also find a way to make it cross-platform because your code is Windows-Specific.
For this, you can use symbols such as #if defined(WINDOWS)