Answers for "how to check if a directory is present or not using c++"

C++
0

how to find out if a directory exists in cpp

#include <sys/stat.h>

int main() {
	struct stat buffer;
    std::string string = "Hello";
    
    if (stat(&string.c_str(), &buffer) != 0) {
    	std::cout << "'Hello' directory doesn't exist!";
    } else {
    	std::cout << "'Hello' directory exists!";
    }
}
Posted by: Guest on July-20-2021

Code answers related to "how to check if a directory is present or not using c++"

Browse Popular Code Answers by Language