Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!stiatl!srchtec!johnb From: johnb@srchtec.UUCP (John Baldwin) Newsgroups: comp.lang.c Subject: Re: Operations on pointers to void. Message-ID: <174@srchtec.UUCP> Date: 14 Aug 90 21:40:57 GMT References: <1990Aug10.165644.9238@zoo.toronto.edu> <482@array.UUCP> <1990Aug12.231202.23826@druid.uucp> Organization: search technology, inc. Lines: 27 In article <1990Aug12.231202.23826@druid.uucp> darcy@druid.uucp (D'Arcy J.M. Cain) writes: >know that the data can be any type but we want to treat it as bytes. Perhaps >we need a new type which acts like void * but allows pointer arithmetic based >on the smallest data type supported by the system, usually (but not always) >a byte. There is a simple fix to this: you can operate on void pointers by casting them to a useful type. For example, perhaps you are writing a function foo() which can take a pointer to anything, and for some (unspecified) reason, you want to "bump" the pointer up three bytes.... SOMETYPE foo( void *myptr, size_t someval, ... ) { . . *((char *)&myptr) += 3; . . } -- John T. Baldwin | johnb@srchtec.uucp Search Technology, Inc. | johnb%srchtec.uucp@mathcs.emory.edu standard disclaimer: | ...uunet!samsung!emory!stiatl!srchtec.. opinions and mistakes purely my own. | ...mailrus!gatech!stiatl!srchtec...