使用Dev c++软件 编译出现问题不知道怎样修正 显示函数定义有误 求解各位
这代码基本上要重写了都,你对于函数的申明、定义甚至if语句的使用的理解,统统都错了。
#include <stdio.h>
#include <string.h>
int main()
{
void mystrcmp(char *, char *); //注意,strcmp已经是库函数了,你要换一个名字
char *p1, *p2, *p3;
char a[100], b[100], c[100];
p1 = &a;
p2 = &b;
p3 = &c;
scanf("%s", p1);
scanf("%s", p2);
scanf("%s", p3);
mystrcmp(a, b);
mystrcmp(b, c);
mystrcmp(a, b);
printf("从小到大输出为:\n%s %s %s", p1, p2, p3);
return 0;
}
void mystrcmp(char * a, char * b)
{
char tmp[100];
if (strcmp(a, b) > 0)
{
strcpy(tmp, a);
strcpy(a, b);
strcpy(b, tmp);
}
}
不知道你这个问题是否已经解决, 如果还没有解决的话:#include<iostream>
#include<cmath>
#define exchange(a,b) t=a;a=b;b=t; //相当于整段代码替换
using namespace std;
int main(){
int a, b, t=0;
cin >> a >> b;
exchange(a,b);
cout << a << " " << b <<endl;
}