这是函数内容:
void CFindFileDlg::OnButton1()
{
UpdateData(true);
CString str,title[1000],name[1000],root[1000];
CFileFind finder;
char *pw;
CString n,Strpath,path;
int i=0;
Strpath=m_EDIT2;
Strpath+= _T("\\*.*");
BOOL bWorking = finder.FindFile(Strpath);
while (bWorking)
{
bWorking = finder.FindNextFile();
if (finder.IsDots())
continue;
if(finder.IsDirectory()) // 搜索 //
{ path=finder.GetFilePath();
Recurse(path);
}//findsubdir
else{
str=finder.GetFileTitle();
pw=strstr(str,m_EDIT1); //比较字符串;
if(pw!=NULL) { i++;if(i<1000){
name[i]=finder.GetFileName();
title[i]=finder.GetFileTitle();
root[i]=finder.GetRoot();}
}
else
SetDlgItemText(IDC_EDIT3,"找不到该文件");
}
}
if(i>0)
{
n="";
for(;i>0;i--)
{n=n+name[i]+"||";}
SetDlgItemText(IDC_EDIT3,n);
SetDlgItemText(IDC_EDIT2,root[i]);
}
else { SetDlgItemText(IDC_EDIT2,"");
SetDlgItemText(IDC_EDIT3,"找不到该文件");
}
}
void CFindFileDlg::OnButton1()
{
UpdateData(true);
CString str,title[1000],name[1000],root[1000];
CFileFind finder;
char *pw;
CString n,Strpath,path;
int i=0;
Strpath=m_EDIT2;
Strpath+= _T("\\*.*");
BOOL bWorking = finder.FindFile(Strpath);
while (bWorking)
{
bWorking = finder.FindNextFile();
if (finder.IsDots())
continue;
if(finder.IsDirectory()) // 搜索 //
{ path=finder.GetFilePath();
Recurse(path);
}//findsubdir
else{
str=finder.GetFileTitle();
pw=strstr(str,m_EDIT1); //比较字符串;
if(pw!=NULL) { i++;if(i<1000){
name[i]=finder.GetFileName();
title[i]=finder.GetFileTitle();
root[i]=finder.GetRoot();}
}
else
SetDlgItemText(IDC_EDIT3,"找不到该文件");
}
}
if(i>0)
{
n="";
for(;i>0;i--)
{n=n+name[i]+"||";}
SetDlgItemText(IDC_EDIT3,n);
SetDlgItemText(IDC_EDIT2,root[i]);
}
else { SetDlgItemText(IDC_EDIT2,"");
SetDlgItemText(IDC_EDIT3,"找不到该文件");
}
}
'function name' : local function definitions are illegalAn attempt was made to define a function within a function.The following is an example that will generate this error:int main()
{
int i = 0; int funcname(int j)
{
j++;
return j;
}
i = funcname(i);
return 0;
}If you move the function into the global space, outside the main() function, the program will compile and run.