Create Directory in Text Editor

Hello everyone,
I am writing a simple Text Editor. At the end of the program, I want to output a *.txt file in a directory the user wants. I know that in order to create directory and subdirectories, I can use this:

SHCreateDirectory(NULL, L"D:\\test\\example");

I want the user to create directories himself. Such as:
main()
{
string link;
std::cin>>link;
}
and user can type: D:\\test\\example

I wonder how I can connect the variable link with the command SHCreateDirectory. Or can I use another command ?

Thanks for your help
Pass it as the second parameter.

 
SHCreateDirectory(NULL, link.c_str());

You have to use c_str() because the function expects a char array, not a std::string.
Thanks, I am trying to do this:

void main()
{
string link;
cin>>link;
SHCreateDirectory(NULL, link.c_str());
}

It returns error: argument of type "const char*" is incompatible with parameter of type "LPCWSTR"
Use std::wstring in that case or use MultiByteToWideChar() API.
Topic archived. No new replies allowed.