樱花流逝
本帖最后由
>>
完整版
本帖最后由 樱花流逝 于 2015-8-29 12:57 编辑
看了4楼的建议后自己又改了一下,发现按照之前那样子在那个位置改s1的话,s1的值会一直继承下去导致所有的文件名都连一起。所以就改成了这个样子:#include <stdio.h>#include <tchar.h>#include<io.h>#include<stdlib.h>#include *本站禁止HTML标签噢*#include *本站禁止HTML标签噢*然而还是错了#pm而且总感觉越来越奇怪了@@26!!using namespace std;int ayu = 0;int change_path(string & path, string new_path){int i = path.length();new_path = new_path + "\\*.*";path.replace(i - 3, i, new_path);return 0;}int find_file( string a ,string b ){string s1,s2;long Handle;if (b.compare("sdf.txt") != 0){ change_path(a, b); }s1.replace(NULL, NULL, a);ayu += 1;cout << ayu << "\t" << s1 << "\t" << endl;struct _finddata_t FileInfo;if ((Handle = _findfirst(a.c_str(), &FileInfo)) == -1L){return 0;}else{printf("123%s\n", FileInfo.name);while (_findnext(Handle, &FileInfo) == 0){if (_A_SUBDIR & FileInfo.attrib){if ((strcmp(FileInfo.name, ".") != 0) && (strcmp(FileInfo.name, "..") != 0)){printf("%s\n", FileInfo.name);s2.replace(NULL, NULL, FileInfo.name);find_file(s1, s2);ayu += -1;}}else{printf("456%s\n", FileInfo.name);}}_findclose(Handle);}return 0;}int _tmain(int argc, _TCHAR* argv[]){string s;cout << "please inupt path:";cin >> s;find_file(s,"sdf.txt");system("pause");return 0;}不知为何字符串粘到一起去了==而且粘的方式还无比奇葩