I don't know why you are doing these many things to get the files in the directory and print the file names with its full path.
You can do this by opendir and readdir functions.I have developed this code in linux environment.
struct dirent *dirp;
printf("Enter the directory name : ");
printf("file name : %s/%s \n",directory,dirp->d_name);
printf("Can not open directory\n");