Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpcc05!hpbbn!hpgnd!guy From: guy@hpgnd.grenoble.hp.com (Guy DUBRISAY) Newsgroups: comp.lang.c Subject: Re: Are addresses of const members const? Message-ID: <1790003@hpgnd.grenoble.hp.com> Date: 8 Feb 91 15:34:28 GMT References: <550@elandes.UUCP> Organization: Hewlett-Packard, GND Lines: 39 'const' is a type modifier whose effect is to tell the compiler that an object such declared cannot be written to (asigned to, incremented, decremented, ...). Statements which are detected by the compiler to do so will cause an error. Obviously any variable may be modified by 'const' argument whatever their type is. Beware of using 'const' modifier altogether with pointers : const char * ptr ; ==> The pointer may be modified, but that which it points to may not. char * const ptr ; ==> The pointer may not be modified, but that which it points to may. const char * const ptr; ==> Neither the pointer nor that which it points to may be modified. Reading your code : >const foo *aray1[] = { &item1, &item2 }; >const bar aray2[] = { &item1, &item2 }; ... should NOT gives 'type mismatch' error! > aray1[0] = &item3; ... is legal (modified pointer). This should cause an error if you had declared const foo * const aray1[] = { &item1, &item2 }; > aray2[0] = &item3; ... must produce an error such as "Cannot assign to a constant." Hope this helps. Guy.