#include<stdio.h>
void main()
{
int a,b;
a=5,b=10;
printf("before swap a=%d,b=%d\n",a,b);
swap(&a,&b);
printf("after swap a=%d,b=%d\n",a,b);
}
swap( px, py)
{
int * px,* py;
int temp;
temp = * px;
* px = * py;
* py = temp;
printf("in swap x=%d,y=%d\n",* px ,* py);
}
运行结果时候
zhizhengmain.cpp
F:\C语言\20130702\zhizhengmain.cpp(7) : error C2065: 'swap' : undeclared identifier
F:\C语言\20130702\zhizhengmain.cpp(10) : error C2065: 'px' : undeclared identifier
F:\C语言\20130702\zhizhengmain.cpp(10) : error C2065: 'py' : undeclared identifier
F:\C语言\20130702\zhizhengmain.cpp(11) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
执行 cl.exe 时出错.
zhizhengmain.obj - 1 error(s), 0 warning(s)
为什么??
浮云间
繁华开满天机