made a mistake on the return values for the last post
I realized that when viewing the logical operator &&, so it should be 1 or 0...
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int isdir(const char *path)
{
struct stat stats;
if(stat(path,&stats) == 0 && S_ISDIR(stats.st_mode) == 0)
return 0;
else
return -1;
}