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) ;
}
为什么编译不过?
解决方案 »
- 无法显示图片 请指教
- 如何实现这种窗口划分
- 很奇怪的问题,这样也能内存操作错误?
- 请问大牛:VC6下如何获取FTP和HTTP文件的属性(最后修改时间和文件大小)
- 如何让透明的Edit控件显示文字?急!
- 文档文件(.txt)中关于中英文混合的格式化输出!
- 大家评论评论新版的CSDN,怎么我老登录不上!
- 请问我怎么在调试的时候实时察看一个变量的值?
- 我愿嫁给你好吗?我的问题太难了。
- 帮帮忙!为什么弹出菜单一定要双击才出现呢?
- 请问高手,我要把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) ;
}