C - How to sheck if a path exists?

How do i check if a path exists in C?

man access

#include <unistd.h>
int access(const char *pathname, int mode);

i am using

            dp = opendir(argv);
            while(entry = readdir(dp)) { 
                stat(entry->d_name, &sbuf);
                if(S_ISDIR(sbuf.st_mode)==1) {
                    sprintf(wordtwo, "%s", entry->d_name);
                        printf(word);
                        printf("/");
                        printf(wordtwo);
                        printf("\n");
                }

for some reason, it prints a file name as well in subdirectories, its supposed to only print it if its a directory, whats wrong with the code?

maybe because of S_ISDIR return 0 as false while others as true.So,it may not be 1 when it's a directory.

if i have a string, and its either the path to a file or directory, how do i check if its a path to file or if its a directory?

stat & S_ISDIR & S_ISREG is a right way.