O'Reilly logo

C++ All-in-One For Dummies, 3rd Edition by John Paul Mueller, Jeff Cogswell

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

Chapter 4

Building Directories and Contents

In This Chapter

arrow Creating and deleting directories

arrow Getting the contents of a directory

arrow Copying and moving, and why they are related

arrow Moving and renaming files and why they are similar

We’re about to say something you might not believe: C++ provides no functions for creating directories and getting the contents of a directory.

Really! We know it’s hard to believe, but we can make two points about this:

  • There really is a (more-or-less) good reason for this lack: C++ is a general-purpose language: Issues that deal with directories are specific to individual operating systems. Thus it doesn’t make sense to include such features in C++. (Supposedly. So they say. We guess. Whatever.)
  • Some brave rebels have added some functions — and these functions exist in most C++ implementations. Whew! That’s a good thing — otherwise you’d have to call in to the operating system to create or modify a directory.

C++ has a holdover from the C programming language in the header file stdio.h that includes functions for renaming and removing files and directories. ...

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