hello there, i was wondering maybe anyone have any example of code, which would show the content of a folder, which path u enter? like i enter the path to the folder and then it prints everything, that's in the folder?
hello there, i was wondering maybe anyone have any example of code, which would show the content of a folder, which path u enter? like i enter the path to the folder and then it prints everything, that's in the folder?
Last edited by apisio; 11-21-2009 at 06:39 AM.
btw, i'm just working with console application.. :P
Make some system calls.
Example:
Simple Directory Lister - The GNU C LibraryCode:#include <stdio.h> #include <sys/types.h> #include <dirent.h> int main (void) { DIR *dp; struct dirent *ep; dp = opendir ("./"); if (dp != NULL) { while (ep = readdir (dp)) puts (ep->d_name); (void) closedir (dp); } else perror ("Couldn't open the directory"); return 0; }
Thank you, seaking1. This is perfect example for me. how can i change the directory? is it this *dp one?
The dp = opendir ("./"); is where the starting directory is named.