[问题]Linux C......
-
- 帖子: 70
- 注册时间: 2008-05-14 10:08
[问题]Linux C......
今天在Linux下写传址的程序,没想到竟然和VC下的差别那么多,下面就是我用vim写的程序:
#include <stdio.h>
void f(int &a)
{
a = 3;
}
int main()
{
int i;
f(i);
printf("%d\n",i);
return 0;
}
用gcc编译后,提示错误:error: expected ';', ',' , or ')' before '&' token
可是当我在VC中编写源程序为:
#include <iostream.h>
void f(int &a)
{
a = 3;
}
void main()
{
int i;
f(i);
cout << i << "\n";
}
VC却显示了 3
我很纳闷,难道我用的不是标准C吗?请教论坛上的高手,谢谢
#include <stdio.h>
void f(int &a)
{
a = 3;
}
int main()
{
int i;
f(i);
printf("%d\n",i);
return 0;
}
用gcc编译后,提示错误:error: expected ';', ',' , or ')' before '&' token
可是当我在VC中编写源程序为:
#include <iostream.h>
void f(int &a)
{
a = 3;
}
void main()
{
int i;
f(i);
cout << i << "\n";
}
VC却显示了 3
我很纳闷,难道我用的不是标准C吗?请教论坛上的高手,谢谢
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
- bones7456
- 帖子: 8495
- 注册时间: 2006-04-12 20:05
- 来自: 杭州
- 联系:
- kofshower
- 帖子: 1343
- 注册时间: 2007-03-13 11:23
- 联系:
Re: [问题]Linux C......
VC g++两边写的都可以作为反面教材sjbird331 写了:今天在Linux下写传址的程序,没想到竟然和VC下的差别那么多,下面就是我用vim写的程序:
#include <stdio.h>
void f(int &a)
{
a = 3;
}
int main()
{
int i;
f(i);
printf("%d\n",i);
return 0;
}
用gcc编译后,提示错误:error: expected ';', ',' , or ')' before '&' token
可是当我在VC中编写源程序为:
#include <iostream.h>
void f(int &a)
{
a = 3;
}
void main()
{
int i;
f(i);
cout << i << "\n";
}
VC却显示了 3
我很纳闷,难道我用的不是标准C吗?请教论坛上的高手,谢谢
"We are all in the mud, but some of us are looking at the stars." (Oscar Wilde)
We are not born for ourselves.
人生天地间,并非为自己
Homepage:http://sites.google.com/site/polarisnotme/
We are not born for ourselves.
人生天地间,并非为自己
Homepage:http://sites.google.com/site/polarisnotme/
- yjcong
- 帖子: 2470
- 注册时间: 2006-02-28 3:11
Re: [问题]Linux C......
lz被批判的太.....kofshower 写了:VC g++两边写的都可以作为反面教材sjbird331 写了:今天在Linux下写传址的程序,没想到竟然和VC下的差别那么多,下面就是我用vim写的程序:
#include <stdio.h>
void f(int &a)
{
a = 3;
}
int main()
{
int i;
f(i);
printf("%d\n",i);
return 0;
}
用gcc编译后,提示错误:error: expected ';', ',' , or ')' before '&' token
可是当我在VC中编写源程序为:
#include <iostream.h>
void f(int &a)
{
a = 3;
}
void main()
{
int i;
f(i);
cout << i << "\n";
}
VC却显示了 3
我很纳闷,难道我用的不是标准C吗?请教论坛上的高手,谢谢
一梦三年,
松风依旧,
萝月何曾老.
灵幽听微, 谁观玉颜?
灼灼春华, 绿叶含丹.
松风依旧,
萝月何曾老.
灵幽听微, 谁观玉颜?
灼灼春华, 绿叶含丹.
- kofshower
- 帖子: 1343
- 注册时间: 2007-03-13 11:23
- 联系:
一直赞成实践的啊。可是起码也要把书看了一遍再说啊。
建议看看The C++ Programming Language 和 The C Programming Language。熟悉其他语言的话看看例子和思考题就ok了
建议看看The C++ Programming Language 和 The C Programming Language。熟悉其他语言的话看看例子和思考题就ok了
"We are all in the mud, but some of us are looking at the stars." (Oscar Wilde)
We are not born for ourselves.
人生天地间,并非为自己
Homepage:http://sites.google.com/site/polarisnotme/
We are not born for ourselves.
人生天地间,并非为自己
Homepage:http://sites.google.com/site/polarisnotme/
-
- 帖子: 70
- 注册时间: 2008-05-14 10:08
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
- kofshower
- 帖子: 1343
- 注册时间: 2007-03-13 11:23
- 联系:
噢 推荐鱼头书 和 K&C,其实ISO c的话和平台无关,windows那个c++那样些有一半的几率是不成的
"We are all in the mud, but some of us are looking at the stars." (Oscar Wilde)
We are not born for ourselves.
人生天地间,并非为自己
Homepage:http://sites.google.com/site/polarisnotme/
We are not born for ourselves.
人生天地间,并非为自己
Homepage:http://sites.google.com/site/polarisnotme/