O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

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

Searching for Files and Directories

A selection of functions in io.h can be used to search directories for files. Again, the Windows API, for example, has specific functions to achieve this, but the standard ANSI C implementation has some cross-platform equivalents.

You have not yet read about abstract data types such as structure, yet the directory search functions require that you populate a structure containing file data. This file data provides a skeleton that can be filled by the file-finding functions; at the outset, you populate it with some basic information, and the file-finding functions will fill it with the details of each file found.

The basic process is as follows:

1.
Find the first file (with skeleton data).
2.
Find the next file. ...

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