создание папки c++
вылетает ошибка :
terminate called after throwing an instance of 'std::filesystem::filesystem_error' what(): filesystem error: cannot create directory: No such file or directory [C:\Users\ys/\18]
получается создать папку указав ей вручную путь для создания, а через переменную никак не могу. Папка уже создана но if все равно пишет что такой папки не существует
вывод в консоль :
C:\Users\ys\CLionProjects\laba17\cmake-build-debug\laba17.exe input set_folder :\18 "C:\Users\ys/\18" folder does'nt exists
namespace fs = std::filesystem;
fs::path operator+(const fs::path &set_folder, const fs::path &user_path) {
return set_folder / user_path;
}
int main() {
const fs::path user_path = "C:\\Users\\ys\17";
fs::path set_folder;
std::cout << "input set_folder :";
std::cin >> set_folder;
fs::path res;
res = user_path / set_folder;
std::cout << res;
if (!std::filesystem::exists(res)){
std::cout << "\nfolder does'nt exists" << std::endl;
std::filesystem::create_directory(res);
} else {
std::cout << "file exists";
}
return 0;
}