<* Source: http://www.51one.net *> # include #include #include #include #include #include void printdir (CHAR * DIR, INT Depth) {DIR * DP; Struct Dirent * Entry; Struct Stat Statbuf; IF ((DP = OpenDir (DIR)) == NULL) {FPRINTF 2, "Can Not Open Directory: S / N", DIR); Return;} ChDir (DIR); while ((entry = readdir (dp))! = Null) {lstat (entry-> d_name, & statbuf); IF (S_ISDIR (STATBUF.ST_MODE)) {if (strcmp ("." == 0 || strcmp ("..", entry-> d_name) == 0) {Continue;} Printf "% * s% s // n", depth, "" ", entry-> d_name); PrintDir (entry-> d_name, depth 4);} else printf ("% * s% s / n ", defth, "", entry-> d_name);} chdir (".."); closedir (DP);} int main () {Printf ("Directory Scan Of / Home / Lzy / PROG_C: / N"); PrintDir (" / home / lzy / prog_c ", 0); Printf (" DONE! "); exit (0);}