Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!mouse From: mouse@thunder.mcrcim.mcgill.edu (der Mouse) Newsgroups: comp.lang.c Subject: is this array access portable? Message-ID: <1991Jun23.185351.5695@thunder.mcrcim.mcgill.edu> Date: 23 Jun 91 18:53:51 GMT Organization: McGill Research Centre for Intelligent Machines Lines: 27 Suppose `sometype' is a type, and `something' is a valid thing to assign to an object of that type, and I write sometype foo[40][50]; sometype *fp; int i; fp = &foo[0][0]; for (i=2000;i>0;i--) *fp++ = something; Is this portable? (The significant question is whether the wraparound from the end of one row to the beginning of the next is guaranteed to work correctly.) I *think* enough promises are made that this will work, but I'd like to get a few second opinions before writing this into some code. The thing that makes me think it has to work is a sentence in the New Testament A7.4.8 (page 204): ``[...]: the size of an array of n elements is n times the size of one element.'', which, applied recursively, appears to imply that the elements of an N-dimensional array must be packed together as if in a one-dimensional array of the appropriate size. (I'm also not *quite* certain that even if this is true, a pointer can sleaze past the boundary safely....) der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu