调用子函数不起作用
#include<stdio.h>void main()
{
void swap(int *p1, int *p2);
int a, b;
int *pointer_1, *pointer_2;
scanf_s("%d %d", &a, &b);
pointer_1 = &a;
pointer_2 = &b;
if (a < b)
{
void swap(int *pointer_1, int *pointer_2);
}
printf(" %d > %d\n", a, b);
}
#include<stdio.h>
void swap(int *p1, int *p2)
{
int temp;
printf("I'm swapping......\n");
printf("Please Wait.........");
temp = *p1;
*p1 = *p2;
*p2 = temp;
}
本帖最后由 jhq999 于 2021-12-24 15:36 编辑
#include<stdio.h>
void main()
{
void swap(int *p1, int *p2);
int a, b;
int *pointer_1, *pointer_2;
scanf_s("%d %d", &a, &b);
pointer_1 = &a;
pointer_2 = &b;
if (a < b)
{
swap(pointer_1, pointer_2);////////////
}
printf(" %d > %d\n", a, b);
}
void swap(int *p1, int *p2)
{
int temp;
printf("I'm swapping......\n");
printf("Please Wait.........");
temp = *p1;
*p1 = *p2;
*p2 = temp;
}
没效果 wenghongzhou 发表于 2021-12-24 19:04
没效果
1 2
I'm swapping......
Please Wait......... 2 > 1
页:
[1]