#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.cppF:\C语言\20130702\zhizhengmain.cpp(7) : error C2065: 'swap' : undeclared identifierF:\C语言\20130702\zhizhengmain.cpp(10) : error C2065: 'px' : undeclared identifierF:\C语言\20130702\zhizhengmain.cpp(10) : error C2065: 'py' : undeclared identifierF:\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)为什么??
3 回答
浮云间
TA贡献1829条经验 获得超4个赞
undeclared identifier的意思你就可以理解为没有定义。
只需要改一下就可以了。
| 123456789101112131415161718 | #include<stdio.h>void swap(int * px,int * py);//提前申明函数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);}viod swap(int * px,int * py){ int temp; temp = * px; * px = * py; * py = temp; printf("in swap x=%d,y=%d\n",* px ,* py);} |
- 3 回答
- 0 关注
- 1109 浏览
添加回答
举报
0/150
提交
取消
