D
D
DmItrENub2022-02-09 21:21:20
C++ / C#
DmItrENub, 2022-02-09 21:21:20

How to convert std::string to LPCSTR?

I'm doing a coursework and I need to pass a std::string. To make another task easier, I want to create a folder, but CreateDirectoryA() takes an LPCSTR, not a std::string. How can I convert std::string to LPCSTR?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2022-02-09
@DmItrENub

std::string dir = "subdir";
CreateDirectoryA(dir.c_str(), nullptr);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question