const真的不变吗? [英] const really constant?
问题描述
const是否真的不变?
在OT上注意:如何使用修改过的电子邮件地址发帖,这样我就可以获得
don''得到这么多垃圾邮件?
2003年9月19日13:38:37 -0700
ne ***** @ tokyo.com (Mantorok Redgormor)写道:const是否真的不变?
不,const是关键字。定义为const的变量在定义后可能不会更改值
。
并且在OT上注释:如何使用修改后的电子邮件地址发布,以便我
阅读新闻阅读器的文档和即兴创作。
- -
char * x(c,k,s)char * k,* s; {if(!k)return * s-36?x(0,0,s + 1):s ; if(s)if(* s)c = 10 +(c?(x(
c,k,0),x(c,k + = * sc,s + 1),* k ):( x(* s,k,s + 1),0));否则c = 10; printf(& x(~0,0,k)[c-〜 -
C +" 1 QUOT; [〜℃下-c],C);}主(){X(0," ^ [kXc6] dn_eaoh
%C"," ; -34 * 1''。+(,03#; +,)/''/// *");}
Mantorok Redgormor< ne * ****@tokyo.com>写道:const是否真的不变?
像Chris Torek总是说,''const''在C中意味着''只读''。当预期的常量表达式时,
不会作为常量,
也不会完全排除对变量的修改。
考虑:
const int x = 10;
int array [x]; / *非法,不是常数表达* /
和
const int x = 10;
int * p =(int *)& x;
* p = 2; / * ooops,刚改了x * /
Alex
Is const really constant?
And on an OT note: how can I post with a modified e-mail address so I
don''t get so much spam?解决方案On 19 Sep 2003 13:38:37 -0700
ne*****@tokyo.com (Mantorok Redgormor) wrote:Is const really constant?
No, const is a keyword. A variable defined to be const may not change value
after definition.
And on an OT note: how can I post with a modified e-mail address so I
don''t get so much spam?
Read your newsreader''s documentation and improvise.
--
char*x(c,k,s)char*k,*s;{if(!k)return*s-36?x(0,0,s+1):s;if(s)if(*s)c=10+(c?(x(
c,k,0),x(c,k+=*s-c,s+1),*k):(x(*s,k,s+1),0));else c=10;printf(&x(~0,0,k)[c-~-
c+"1"[~c<-c]],c);}main(){x(0,"^[kXc6]dn_eaoh
%c","-34*1''.+(,03#;+,)/''///*");}
Mantorok Redgormor <ne*****@tokyo.com> wrote:Is const really constant?
Like Chris Torek always says, ''const'' in C means ''read-only''. It
does not act as a constant when a constant expression is expected,
nor does it completely preclude modifications to the variable.
Consider:
const int x = 10;
int array[x]; /* ilegal, not constant expression */
and
const int x = 10;
int *p = (int *)&x;
*p = 2; /* ooops, just changed x */
Alex
这篇关于const真的不变吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!