kidcad 发表于 2020-5-24 16:48:59

c语言函数调用问题

各位大佬,我太久不用c了,有点疑惑
像下面这个调用compare_bt_lefts
不需要加参数调用吗?像这样:compare_bt_lefts(a,b);
是因为都是const吗?
qsort(selected_detections, selected_detections_num, sizeof(*selected_detections), compare_by_lefts);

int compare_by_lefts(const void *a_ptr, const void *b_ptr) {
    const detection_with_class* a = (detection_with_class*)a_ptr;
    const detection_with_class* b = (detection_with_class*)b_ptr;
    const float delta = (a->det.bbox.x - a->det.bbox.w/2) - (b->det.bbox.x - b->det.bbox.w/2);
    return delta < 0 ? -1 : delta > 0 ? 1 : 0;
}

永恒的蓝色梦想 发表于 2020-5-24 16:55:06

这是传了个函数,不是传的函数返回值

xiaosi4081 发表于 2020-5-24 16:56:57

这是函数传值

xiaosi4081 发表于 2020-5-24 17:02:06

楼上正解

kidcad 发表于 2020-5-26 16:11:44

永恒的蓝色梦想 发表于 2020-5-24 16:55
这是传了个函数,不是传的函数返回值

谢谢!
页: [1]
查看完整版本: c语言函数调用问题