I know how to use the file_pointer=fopen("location","type") to open and check if a file exists. But I'm not sure how I would use this command or a similar one to check if a folder exists?

What command do I have to use to check if a folder exists in the current directory?

It depends on what system you're on. If you're on windows you can use GetFileAttributes (google it) and & it with FILE_ATTRIBUTE_DIRECTORY .

Use chdir. stat also works, although it may lead to race condition.

Use chdir. stat also works, although it may lead to race condition.

we're using linux. and how would I chdir it from a C program? Even if i make a system call, there is no way to get the results of the system call back is there?

On *nix you can call the function opendir() to check if a directory exists. You can use fopen() to do that. I believe stat() will also work on directories.