Answers for "check if directory exists cpp"

C++
2

check if directory exists cpp

#include <sys/stat.h>

bool IsPathExist(const std::string &s)
{
  struct stat buffer;
  return (stat (s.c_str(), &buffer) == 0);
}
Posted by: Guest on June-28-2021
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 "check if directory exists cpp"

Browse Popular Code Answers by Language