Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: pointers to arrays Message-ID: <15981@mimsy.UUCP> Date: 16 Feb 89 16:31:36 GMT References: <19784@uflorida.cis.ufl.EDU> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 39 In article <19784@uflorida.cis.ufl.EDU> thoth@beach.cis.ufl.edu (Robert Forsman) writes: >... Gordon Cross wants to take the address of an array.... My >question is "what will you use this for?" For whatever you like. E.g.: f(ptr_to_array, number_of_arrays) int (*ptr_to_array)[30]; int number_of_arrays; { int i; for (i = 0; i < number_of_arrays; i++) (*ptr++)[5] = 42; } foo() { int first[2][30]; int second[30]; f(first, 2); /* now first[0][5] = 42 and first[1][5] = 42 */ f(&second, 1); /* now second[0][5] = 42 */ ... } Without allowing `&array' you must write f((int (*)[30])second, 1); which is after all rather silly. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris