void fun()
{
qsort (plist->info, iNum, sizeof (FILEINFO), Compare) ;
}int Compare (const FILEINFO * pinfo1, const FILEINFO * pinfo2)
{
return lstrcmp (pinfo2->szFilename, pinfo1->szFilename) ;
}
为什么编译不过?
{
qsort (plist->info, iNum, sizeof (FILEINFO), Compare) ;
}int Compare (const FILEINFO * pinfo1, const FILEINFO * pinfo2)
{
return lstrcmp (pinfo2->szFilename, pinfo1->szFilename) ;
}
为什么编译不过?
解决方案 »
- select模型的使用?
- 求助:关于传输文字显示问题
- 有谁知道codeproject网站怎么了?我这里一直进不去!郁闷!散分
- 如何在网页下载完成后,DocumentComplete 以前 修改网页的内容
- 一个很急很菜的问题,文件结尾的问题
- 怎样使用全局变量?
- 关于std::__Fiopen 和using namespace
- 刚刚送了20分,可是没能解决问题,VC彻底瘫痪,诚征解决方法。
- 一段很短,但很费解的英文。 翻译完分数立即结。
- 高分求救:怎么能得到一个字符串的外观边界
- 请问高手,我要把200多个点的数据(坐标值)转化为图形,应该用怎样的方案来解决。是让图形在对话框中显示出来还是在视图中显示出来,或
- 为什么让我遇到这么一个难题!如果以后再也遇不到这么难的问题怎么办?救命啊(急得在地下打滚)....
void qsort(
void *base,
size_t num,
size_t width,
int (__cdecl *compare )(const void *, const void *)
);
base
Start of target array.
num
Array size in elements.
width
Element size in bytes.
compare
Comparison function. The first parameter is a pointer to the key for the search and the second parameter is a pointer to the array element to be compared with the key.
void qsort(
void *base,
size_t num,
size_t width,
int (__cdecl *compare )(const void *, const void *)
);
base
Start of target array.
num
Array size in elements.
width
Element size in bytes.
compare
Comparison function. The first parameter is a pointer to the key for the search and the second parameter is a pointer to the array element to be compared with the key.
E:\VCPROJECT\INTERNET\UPDDEMO\dd.cpp(443) : error C2664: 'qsort' : cannot convert parameter 4 from 'int (const FILEINFO *,const FILEINFO *)' to 'int (__cdecl *)(const void *,const void *)'
None of the functions with this name in scope match the target type
这样改写:int Compare (const void* pinfo1, const void* pinfo2)
{
return lstrcmp ((FILEINFO*)pinfo2->szFilename, (FILEINFO*)pinfo1->szFilename) ;
}
{
/* Compare all of both strings: */
return _stricmp( * ( char** ) arg1, * ( char** ) arg2 );
}
{
return _stricmp((FILEINFO *)pinfo2->szFilename, (FILEINFO *)pinfo1->szFilename);
}
按照你的做法改了一下dd.cpp
E:\VcProject\Internet\UPDDEMO\dd.cpp(454) : error C2227: left of '->szFilename' must point to class/struct/union
E:\VcProject\Internet\UPDDEMO\dd.cpp(454) : error C2227: left of '->szFilename' must point to class/struct/union
int Compare (const FILEINFO * pinfo1, const FILEINFO * pinfo2)
{
return lstrcmp (pinfo2->szFilename, pinfo1->szFilename) ;
}
---->
int Compare (void * pinfo1, void * pinfo2)
{
return lstrcmp ((FILEINFO*)pinfo2->szFilename, (FILEINFO*)pinfo1->szFilename) ;
}