Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!aussie!rex From: rex@aussie.UUCP (Rex Jaeschke) Newsgroups: comp.std.c Subject: Re: A simple typing question. Message-ID: <36.UUL1.3#5077@aussie.UUCP> Date: 13 Feb 90 16:39:16 GMT References: <25D7D0BE.17645@paris.ics.uci.edu> Organization: Journal of C Language Translation Lines: 33 > Ronald Guilmette writes: > The question really is: "What is the type of a?" Is the type of `a' > simply `int *' or is it `int * const'? > > */ > > int *p; > > void function (int a[]) > { > a = p; > } In the scope of a definition (or an extern declaration) of an array, the array name IS a const pointer. Not so though when used as a formal parameter. At that stage arrays and pointers are synonymous. In fact ANSI C requires that arguments be passed by value and that a private MODIFIABLE copy be made available to the called function. As such, a++ is valid inside function above. If, however, the formal parmeter were declared as (int * const a) then a would be a const pointer. (I don't see how to declare as such using array notation though since const int a[] is NOT the same thing.) Rex ---------------------------------------------------------------------------- Rex Jaeschke | Journal of C Language Translation | C Users Journal (703) 860-0091 | 2051 Swans Neck Way | DEC PROFESSIONAL uunet!aussie!rex | Reston, Virginia 22091, USA | Programmers Journal ---------------------------------------------------------------------------- Convener of the Numerical C Extensions Group (NCEG) ----------------------------------------------------------------------------