how i can read the contents of directory

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.
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.