初级会员

- 积分
- 84
- 金钱
- 84
- 注册时间
- 2015-4-14
- 在线时间
- 0 小时
|

楼主 |
发表于 2015-8-30 14:30:58
|
显示全部楼层
回复【2楼】yangzhen86:
---------------------------------
VC++6.0通不过,我试过了。keil一点错误都没。
试了几种情况
const char test[12]={"hello world!"};//OK
const char test[12]={'h','e','l','l','o',' ','w','o','r','l','d','!'};//OK
const char test[12]={"hello world!!"};// error: #144: a value of type "char [14]" cannot be used to initialize an entity of type "const char [12]"
const char test[12]={'h','e','l','l','o',' ','w','o','r','l','d','!','\0'};// error: #146: too many initializer values
所以我想编译器没那么SB吧,另外两种错误都能识别,这个const char test[12]={"hello world!"};如果会越界没道理不报错啊。 |
|