指针和整数之间的比较[默认启用] [英] comparison between pointer and integer [enabled by default]
本文介绍了指针和整数之间的比较[默认启用]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要检查与check_line和check_triangle使用geo_analyzer函数的结果。感谢您对AP preciated答案。我不知道为什么我得到的错误。此外,我编译在Ubuntu
我得到的错误在这里
如果(check_line == 1)
返回1; //行如果(check_triangle == 1)返回2; //三角形
在函数的函数code
双calculateSlop(双A,双B,双C,双D){ 返回(D-C)/(B-A); //像(Y2-Y1)/(X2-X1)
}INT geo_analyzer(双p1_x,双p1_y,双p2_x,双
p2_y,双p3_x,双p3_y,双p4_x,双p4_y){ 双M1,M2,M3; M1 = calculateSlop(p1_x,p2_x,p1_y,p2_y);
M2 = calculateSlop(p2_x,p3_x,p2_y,p3_y);
M3 = calculateSlop(p3_x,p4_x,p3_y,p4_y); 如果(check_line == 1){
返回1; //行
}
如果(check_triangle == 1){
返回2; //三角形
}
}
解决方案
您与整数比较函数指针。如果你需要的函数的输出,通过 check_line(ARG1,ARG2,ARG3,...)
。
I want to check result with geo_analyzer function using by check_line and check_triangle. Thank you for appreciated answers. I don't know why I get the error. Besides I compile on ubuntu I get error here
if(check_line==1)
return 1; // line
if(check_triangle==1)
return 2; //triangle
code of the function in function
double calculateSlop(double a,double b,double c,double d){
return (d-c)/(b-a); // like (y2-y1)/(x2-x1)
}
int geo_analyzer( double p1_x, double p1_y, double p2_x, double
p2_y, double p3_x, double p3_y, double p4_x, double p4_y){
double m1,m2,m3;
m1=calculateSlop(p1_x,p2_x,p1_y,p2_y);
m2=calculateSlop(p2_x,p3_x,p2_y,p3_y);
m3=calculateSlop(p3_x,p4_x,p3_y,p4_y);
if(check_line==1){
return 1; // line
}
if(check_triangle==1){
return 2; //triangle
}
}
解决方案
You are comparing a function pointer with an integer. If you need the output of the function, call it by check_line(arg1, arg2, arg3, ...)
.
这篇关于指针和整数之间的比较[默认启用]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文