write a c++ function that removes a directory
- User
write a c++ function that removes a directory
Assistant
Here's an example of a C++ function that removes a directory:
#include <iostream> #include <string> #include <filesystem> void removeDirectory(const std::string& directoryPath) { // Check if the directory exists if (!std::filesystem::exists(directoryPath)) { std::cerr << "Error: Directory does not exist: " << directoryPath << std::endl; return; } // Check if the directory is not empty if (std::filesystem::is_empty(directoryPath)) { std::cerr << "Error: Directory is not empty: " << directoryPath << std::endl; return; } // Remove the directory std::filesystem::remove_directory(directoryPath); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.