博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C/C++的全局变量能否利用函数初始化?
阅读量:4140 次
发布时间:2019-05-25

本文共 313 字,大约阅读时间需要 1 分钟。

      先来看一个C++程序(.cpp):

#include 
int fun(int x){ return x * x;}int a = fun(10);int main(){ printf("a = %d\n", a); return 0;}
      居然得出了100的结果, 吓我一跳。 

      再看C程序(.c):

#include 
int fun(int x){ return x * x;}int a = fun(10);int main(){ printf("a = %d\n", a); return 0;}
     编译错误, 符合我的预期。

     上述编译器都是VC++6.0.   有兴趣的读者可以深究一下。

转载地址:http://txrvi.baihongyu.com/

你可能感兴趣的文章
北京十大情人分手圣地
查看>>
Android自动关机代码
查看>>
Android中启动其他Activity并返回结果
查看>>
2009年33所高校被暂停或被限制招生
查看>>
GlassFish 部署及应用入门
查看>>
iWatch报错: Authorization request cancled
查看>>
iWatch报错: Authorizationsession time out
查看>>
X-code7 beta error: warning: Is a directory
查看>>
Error: An App ID with identifier "*****" is not avaliable. Please enter a different string.
查看>>
iTunes Connect 上传APP报错: Communication error. please use diagnostic mode to check connectivity.
查看>>
3.5 YOLO9000: Better,Faster,Stronger(YOLO9000:更好,更快,更强)
查看>>
iOS菜鸟学习--如何避免两个按钮同时响应
查看>>
How to access the keys in dictionary in object-c
查看>>
iOS菜鸟学习—— NSSortDescriptor的使用
查看>>
hdu 3787 hdoj 3787
查看>>
hdu 3790 hdoj 3790
查看>>
hdu 3789 hdoj 3789
查看>>
hdu 3788 hdoj 3788
查看>>
zju 1003 zoj 1003
查看>>
zju 1004 zoj 1004
查看>>