delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/29/17:45:30

From: guille AT iies DOT XXes (Guillermo Rodriguez Garcia)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Dereferencing a void pointer
Date: Tue, 29 Jun 1999 20:59:47 GMT
Organization: Telefonica Transmision de Datos
Lines: 21
Message-ID: <3778e9c8.2996953@noticias.iies.es>
References: <01bebdc4$9b2e6020$LocalHost AT scarfboy DOT tip DOT nl>
NNTP-Posting-Host: iies238.iies.es
Mime-Version: 1.0
X-Newsreader: Forte Agent 1.5/32.451
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

El día 23 Jun 1999 22:02:41 GMT, "Bart Alewijnse"
<scarfman AT geocities DOT com> escribió:

>I have a struct with a 'void *data' member, of which the type I assign when
>I
>judge what data goes in it. The compiler yaks at me when I try to offset it
>like:
>
> to->data[offset]=0;

In order to add the offset to the pointer, the compiler just needs to
know what data type that pointer is pointing at. If this 'offset' you
are using is just an arbitrary number of _bytes_, try:

((unsigned char *)(to->data))[offset] = 0;

Regards,
G.
----
Guillermo Rodriguez Garcia
guille AT iies DOT XXes (remove the XX)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019