Use stat() [man 2 stat], then check the st_mode field. There is a macro S_ISDIR() which takes the st_mode field and
returns true if the stat'ed thing is a directory.
Use mkdir() [man 2 mkdir]. One of its parameters is the permissions to use.
(At least, these are both POSIX compliant. If you want true platform independence, you'll need to use a library
such as boost::filesystem).