Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Teaching const: decoding declarations Message-ID: <10995@mimsy.UUCP> Date: 9 Apr 88 17:22:25 GMT References: <7712@apple.Apple.Com> <3034@haddock.ISC.COM> <613@mcrware.UUCP> <9683@ism780c.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 35 -In article <27071@amdahl.uts.amdahl.com> nw@amdahl.uts.amdahl.com -(Neal Weidenhofer) writes: -> int * const a; ->decodes as: -> a is a constant, -> a is a constant pointer, -> a is a constant pointer to an int. -> (i.e., a cannot be modified but *a can.) In article <9683@ism780c.UUCP> news@ism780c.UUCP (News system) writes: -Note that: - int a[1]; -decodes as: - a is a constant, Nope. - a is a constant pointer, - a is a constant pointer to an int. - (i.e., a cannot be modified but *a can.) - -But there must (?) be some difference between the two. How do you teach -this? Start with the right expansion: a is an array 1 of int (i.e., `a' used in rvalue contexts is an object of type pointer to int, but a cannot be modified because it is an array). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris