To change the current working directory of your program (which will be where you are when you run it:
Code:
#include<unistd.h>
chdir("path");
To list the contents of a directory:
Code:
#include<dirent.h>
DIR *dp;
struct dirent *dirp;
if((dp=opendir("path"))==NULL){
perror();
exit(1);
}
while((dirp = readdir(dp)) != NULL){
printf("%s\n",dirp->d_name);
}
also check out the man pages on those functions
Enjoy!