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/06/24 00:44:43
![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](/uploads/image/z/14706061-61-1.jpg?t=int+same_different%28%29+%7B+if%28strcmp%28p1.x%2Cp2.x%29+%26%26+strcmp%28p1.y%2Cp2.y%29%29+return+0%3B+else+return+1%3B+%7Dtypedef+struct+%7B%5Cx05int+x%2Cy%3B%7Dline%3Bline+p1%2Cp2%3Bint+same_different%28%29%7B%5Cx05if%28strcmp%28p1.x%2Cp2.x%29+%26%26+strcmp%28p1.y%2Cp2.y%29%29%5Cx05%5Cx05return+0%3B%5Cx05else%5Cx05%5Cx05return+1%3B%7Dwar)
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;
}