Answer the question
In order to leave comments, you need to log in
How to create a directory whose name consists of a variable?
There is a task: To make "registration". It is conceived so that the user enters his login, and the program creates a folder with his login.
string login;
cout << "Enter login: ";
cin >> login;
CreateDirectory(L"D:\\Test\\" + login.c_str(), NULL);
Answer the question
In order to leave comments, you need to log in
You're wrong because you're trying to apply the "+" operator to two C-strings.
#include <iostream>
#include <filesystem>
int main(int argc, char** argv)
{
std::cout << "Enter your login: " << std::endl;
std::string login;
std::getline(std::cin, login);
std::filesystem::create_directory("D:/Test/" + login);
return 0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question