logo CodeStepByStep logo

You are working on problem set: Recursion Problems ( Pause)

crawl

Language/Type: C++ recursion file input
Related Links:

Write a recursive function named crawl that accepts a string for a file or directory name as a parameter and prints information about that file or directory. If the name represents a normal file, just print its name. If the name represents a directory, print its name and information about every file/directory inside it, indented by 4 spaces at each level. For example, the call of crawl("course") might print the following information about your course directory:

course
    handouts
        lecture-schedule.xls
        syllabus.doc
    homework
        1-gameoflife
            GameOfLife.zip
            life.cpp
            life.h

Constraints: Your function must be recursive, though you may use a loop to help you as appropriate.

Function: Write a C++ function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? .

If something seems wrong with our site, please

Is there a problem? Contact us.