请求修改一个程序,不知道为什么会这样呢
#include "stdio.h"main()
{void swap(int,int);
int a,b;
a=3;b=4;
swap(a,b);
printf("%d,%d\n",a,b);
}
void swap(int x,int y)
{int t;
t=x;x=y;y=t;
}
小弟不才,请求指教!
当然..外部声明和main()函数声明都可以~!~(如果所有函数都定义在主函数下面.而且仅仅供主函数调用的话)
我记得C语言的书指针那一章的第一个例子就是它了..
给你参照一下:
#include<stdio.h>
main()
{
void swap();
int a=3,b=4;
printf("%d,%d\n",a,b);
swap(&a,&b);
printf("%d,%d\n",a,b);
}
void swap(x,y)
int *x,*y;
{
int temp;
temp=*x;
*x=*y;
*y=temp;}