Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!brl-tgr!tgr!cottrell@nbs-vms.ARPA From: cottrell@nbs-vms.ARPA Newsgroups: net.lang.c Subject: array refs Message-ID: <7225@brl-tgr.ARPA> Date: Fri, 11-Jan-85 10:56:30 EST Article-I.D.: brl-tgr.7225 Posted: Fri Jan 11 10:56:30 1985 Date-Received: Sun, 13-Jan-85 08:21:32 EST Sender: news@brl-tgr.ARPA Organization: Ballistic Research Lab Lines: 27 /* i disagree about referencing arrays 'out of bounds'. i have often taken a pointer, moved it down the array, when suddenly i find i have to pervert the previous character. what do i do? something like: p[-1] = ... ; i see nothing wrong with negative indexing, altho i dont believe in floating point :-) also: about the construct: for(p = buf; p < &buf[SIZE]; p++) someone said it breaks at the wraparound point of memory. true, but lotsa weird stuff happens there. i know p <= &buf[SIZE - 1] works there, but this is a pathological case. most programs deal with address space that look like 0 < lo < hi < wrap. also also: another use of array refs beyond the 'bounds' is a struxure that ends with a variable size string: struct weird { int count; ... ... char string[1]; }; w = malloc(sizeof(struct weird) + strlen(source); w->count = strlen(strcpy(w->string,source)); howzabout them apples? */