O'Reilly logo

APIs at Work, Second Edition by Ron Hawkins, Doug Pence, Bruce Vining

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading a Directory Entry

The readdir API reads the next entry within a directory. The first time you call readdir, the “next” entry is the first entry in the directory. Use readdir to sequentially read through the contents of a directory. Use the rewinddir API if you need to reposition readdir back to the first entry of the directory.

The parameter description for the readdir API is shown in Figure 14.15. This API takes just one parameter, Dirp, which is defined as a pointer to DIR. This is the pointer that was returned by the opendir API.

Figure 14.15. The readdir API.
struct dirent *readdir (DIR *dirp)

The readdir API also returns a pointer that points at a structure of type dirent. The dirent structure is defined in the API documentation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required