我昨天查的32位编译器没有超过4个字节的型态~
某些特殊C编译器是有~但是不是我用的那种~
我的构想是取出字元转ASCII码去比大小~
只是代码有问题会当机~帮忙看看为何~
用编译器跑时都正常~但是用执行档跑就会当~
unsigned long GetFileList(char *Feature,char *Path)
{
WIN32_FIND_DATA FindFileData;
HANDLE hFindFile;
BOOL bFind;
DWORD dwFileAttributes;
INT nTotalChildDirectory;
char FPath[Max_Size]={0},strFileName[Max_Size]={0};
unsigned long FSize=0;
lstrcpy(FPath,Path);
int len = lstrlen(FPath);
if(FPath[len - 1] != '\\')
lstrcat(FPath, "\\");
lstrcat(FPath,Feature);
lstrcat(FPath, "*.txt");
nTotalChildDirectory = 0;
bFind = TRUE;
dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
hFindFile = FindFirstFile(FPath, &FindFileData);
while(bFind && (hFindFile != INVALID_HANDLE_VALUE))
{
if((FindFileData.dwFileAttributes & dwFileAttributes) == dwFileAttributes)
{
lstrcat(strFileName, FindFileData.cFileName);
nTotalChildDirectory++;
}
else
{
lstrcat(FileList[FileCount], FindFileData.cFileName);
FileCount++;
FSize=FSize+FindFileData.nFileSizeLow;
}
bFind = FindNextFile(hFindFile, &FindFileData);
}
if(hFindFile != INVALID_HANDLE_VALUE) FindClose(hFindFile);
if (FileCount>1){BubbleSort(FileCount);}//*********
return FSize;
}
void BubbleSort(unsigned int FCount)
{
unsigned int i=0,j=0,k=0;
char temp[Max_Size]={0};
for(i=0;i<FCount;i++)
{
for(j=i+1;j<FCount-1;j++)
{
for(k=0;k<strlen("GHK156.1_11_130723130821.txt");k++)
{
char A[1]={0},B[1]={0};
int AA=0,BB=0;
substr(A,FileList[j],k,1);
AA=*A;
substr(B,FileList[i],k,1);
BB=*B;
if(AA!=BB)
{
if(AA<BB)
{
strcpy(temp,FileList[j]);
memset(FileList[j],0,sizeof(FileList[j]));
strcpy(FileList[j],FileList[i]);
strcpy(FileList[i],temp);
memset(temp,0,sizeof(temp));
}
break;
}
}
}
}
}
void substr(char *dest, const char* src, unsigned int start, unsigned int cnt)
{
strncpy(dest, src + start, cnt);
dest[cnt] = 0;
}
[
本帖最后由 wube 于 2013-7-31 13:48 编辑 ]