delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/10/11/08:51:47

From: Xudong Xie <xiex AT cs DOT curtin DOT edu DOT au>
Subject: void *
To: djgpp AT sun DOT soe DOT clarkson DOT edu (djgpp mail list)
Date: Tue, 11 Oct 1994 16:29:43 +0800 (WST)

Hi there,

I'm a new C programmer so the following question may sound a bit silly.  Please help me anyway.

I'm currently develop a program that has a function that doesn't know what the parameter type will be (it will be a struct).  I declare that param as void * and pass its size to the function:

	foo( void *s, size_t size )

Inside the function, I need to access the struct.  K&R (2nd ed p.199) says that the original pointer can be recovered if s is converted back to the oringinal pointer type.  Since I don't know what the original is when writing this function, I can't really do that conversion.  I think that maybe I can make a hex dump in this situation.  But I don't know how to do it.  Can anybody give me some advice to this problem?
 
Thanks in advance.


Donald Xie

**********************************************************
*  Donald X. Xie                                         *
*  School of Computing Science, Curtin U. of Technology  *
*  Perth, Western Australia, Australia                   *
*  Email: xiex AT cs DOT curtin DOT edu DOT au                          *
**********************************************************


- Raw text -


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