How to check if directory exists in C++

The dirent.h header file provides the opendir. Its purpose is to open a directory path to read with other calls. However, this is also a good way to check if the directory exists. If the input directory path does not exist or is a file, then this function return NULL.

Tried with: Ubuntu 14.04