how i can read the contents of directory

Aug 11, 2008 at 6:09am
hi,

how can i read the contents of directory.
suppose a directory is having some .txt files. now i want to read all the file one by one. how can i implement a code in c++.

Thanking you,
srinivas.
Aug 11, 2008 at 1:47pm
Use opendir() and readdir(). (man 3 opendir and man 3 readdir).
Continue calling readdir() until it returns NULL. Each call to readdir returns the "next" directory entry. Be aware that readdir() will return "." and ".." as directory entries...

Topic archived. No new replies allowed.