int same_different() { if(strcmp(p1.x,p2.x) && strcmp(p1.y,p2.y)) return 0; else return 1; }typedef struct {\x05int x,y;}line;line p1,p2;int same_different(){\x05if(strcmp(p1.x,p2.x) && strcmp(p1.y,p2.y))\x05\x05return 0;\x05else\x05\x05return 1;}war
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/16 19:25:55
int same_different() { if(strcmp(p1.x,p2.x) && strcmp(p1.y,p2.y)) return 0; else return 1; }typedef struct {\x05int x,y;}line;line p1,p2;int same_different(){\x05if(strcmp(p1.x,p2.x) && strcmp(p1.y,p2.y))\x05\x05return 0;\x05else\x05\x05return 1;}war
int same_different() { if(strcmp(p1.x,p2.x) && strcmp(p1.y,p2.y)) return 0; else return 1; }
typedef struct {
\x05int x,y;
}line;
line p1,p2;
int same_different()
{
\x05if(strcmp(p1.x,p2.x) && strcmp(p1.y,p2.y))
\x05\x05return 0;
\x05else
\x05\x05return 1;
}
warning C4047:'function' :'const char *' differs in levels of indirection from 'int '
warning C4024:'strcmp' :different types for formal and actual parameter 1
我封装的这个函数 strcmp函数怎么使用呢?我知道是字符串的比较.代码哪里错了怎么错了?
int same_different() { if(strcmp(p1.x,p2.x) && strcmp(p1.y,p2.y)) return 0; else return 1; }typedef struct {\x05int x,y;}line;line p1,p2;int same_different(){\x05if(strcmp(p1.x,p2.x) && strcmp(p1.y,p2.y))\x05\x05return 0;\x05else\x05\x05return 1;}war
strcmp用于比较字符串的,你是整数型,所以参数类型不匹配,改成:
int same_different()
{
if((p1.x==p2.x)&& (p1.y==p2.y))
return 0;
else
return 1;
}