这是为什么,我上网搜了.cpp是标准的c++源程序,但是我写的确实是C源程序。
给大家附上我的一段出问题的代码!超简单的
#include
void swap(int &x,int &y){
x++;
y++;
}
void main(){
int a=1;
int b=2;
swap(a,b);
printf("%d\t%d",a,b);
if(true) //报错居然告诉我true没有定义,我直接无语啊!这也太夸张了吧!
printf("asdas");
}
--------------------Configuration: test - Win32 Debug--------------------
Compiling...
test.c
K:\语言学习\vc 6.0\temp\test.c(2) : error C2143: syntax error : missing ')' before '&'
K:\语言学习\vc 6.0\temp\test.c(2) : error C2143: syntax error : missing '{' before '&'
K:\语言学习\vc 6.0\temp\test.c(2) : error C2059: syntax error : '&'
K:\语言学习\vc 6.0\temp\test.c(2) : error C2059: syntax error : ')'
K:\语言学习\vc 6.0\temp\test.c(9) : warning C4013: 'swap' undefined; assuming extern returning int
K:\语言学习\vc 6.0\temp\test.c(12) : error C2065: 'true' : undeclared identifier
执行 cl.exe 时出错.
test.obj - 1 error(s), 0 warning(s)
————————————————————————————
改成.cpp就好了
--------------------Configuration: test - Win32 Debug--------------------
Compiling...
test.cpp
test.obj - 0 error(s), 0 warning(s)
————————————————————————————————————
求解释,这以后编C语言程序到底写什么后缀名!
难道冒充 C++写 .cpp??????
求解释!