Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site orion.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!houxm!hogpc!houti!ariel!hou4b!hou5f!orion!john From: john@orion.UUCP Newsgroups: net.lang.c Subject: offsets in structures. Message-ID: <393@orion.UUCP> Date: Fri, 5-Oct-84 16:44:32 EDT Article-I.D.: orion.393 Posted: Fri Oct 5 16:44:32 1984 Date-Received: Sat, 6-Oct-84 05:25:26 EDT Organization: AT&T Information Systems, Holmdel NJ Lines: 24 [] Here's a little *trick* that I picked up today to calculate offsets of elements in structures. #define OFFSET(X, Y) ((struct X *)0)->Y e.g. offset for an integer field -- &OFFSET(mystruct, anyint) offset for a character array -- OFFSET(mystruct, arrayname) Although there are more readable ways to write this using +/- and & I reckon its kinda neat. Also from the same source.... e.g. to rename files with suffix .n without suffix for i in *.n do ifs=$IFS; IFS=.; set $i; IFS=$ifs cp $i $1 done orion!john