1. There are some code problems on the Internet, improve the following
#include <stdio.h> #include <windows.h> #include <iostream> #include <string>using namespace Std;int count = 0;void Find (char * lppath) {char Save_path[200];char Szfile[max_path] = {0};char Szfind[max_path];char root [MAX_PATH]; Win32_find_data findfiledata;strcpy (Szfind,lppath); Strcat (Szfind, "* *"); HANDLE Hfind=::findfirstfile (Szfind,&findfiledata); if (Invalid_handle_value = = hfind) return;while (TRUE) {if ( Findfiledata.dwfileattributes & File_attribute_directory) {if (findfiledata.cfilename[0]!= '. ') {strcpy (Szfile,lppath);//strcat (Szfile, "//"); strcat (szfile,findfiledata.cfilename); Strcat (Szfile, "//"); Find ( szfile);}} else{strcpy (Root, Lppath); strcat (root,findfiledata.cfilename); cout << root << endl;} if (! FindNextFile (Hfind,&findfiledata)) break; FindClose (hfind);} void Main () {Find ("... 2003//");}
Windows API recursively traverses all files under Folders