Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/types.h>
- #include <dirent.h>
- int main(int argc, char** argv)
- {
- DIR *dp;
- struct dirent *ep;
- int counter = 0;
- if(argc != 2)
- {
- printf("USAGE: %s /path/to/dir\n", argv[0]);
- return 0;
- }
- dp = opendir(argv[1]);
- if (dp != NULL)
- {
- while (ep = readdir(dp))
- {
- puts(ep -> d_name);
- if(counter == 1000)
- break;
- counter++;
- }
- (void) closedir(dp);
- }
- else
- perror("Couldn't open the directory.");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement