2

Possible Duplicate:
How do you get a directory listing in C?
Listing directory contents using C and Windows

How do you write a program which lists the directories recursively just like dir /s C:\ in the command prompt?

melpomene
  • 81,915
  • 7
  • 76
  • 137
user1758596
  • 266
  • 2
  • 13

2 Answers2

1

You can call the Windows API FindFirstFile and FindNextFile to iterate in a directory and do it recursively on subdirectories. See the Example on MSDN.

lqs
  • 1,394
  • 10
  • 20
1

To list file contents you can search a directory with these APIs:

You'll need to #include <windows.h>, that'll get you access to the Windows API. They're C functions and so compatible with C++. If you want "specifically C++", try searching for listing directories using MFC.

Lundin
  • 174,148
  • 38
  • 234
  • 367
Jainendra
  • 23,989
  • 30
  • 120
  • 167