Saturday, March 12, 2011

C++ List files in a directory

Hi guys, in this post we see on how to list files in a directory. Basically we include dirent.h which specifies the format of directory entries in Linux.

WINDOWS users click here

In Linux it also lists files with names "." and ".." which are related to OS and do not qualify as regular files that we are interested in so we skip those files by checking the length of the name of the file (to be <2). Change the code as you wish.

No comments:

Post a Comment