TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: PAUL DRUGGITT
from: CLIFF RHODES
date: 1997-05-18 21:51:00
subject: passing structures to fu

--> Paul Druggitt wrote to All  <--
PD> Can anyone tell me how to pass structures of different sizes to a
PD> function ?
PD> 
PD> I know how to pass a structure of a known size, e.g.
PD>                                  ^^^^^^^^^^^^^^^
PD> Now, is it possible to write a single function that will accept
PD>ANY  structure as a parameter, stating which member to compare?
PD> 
PD> eg.
PD> 
PD> int main(void)
PD> {
PD> 
PD>     display_data(&DATA, DATA.type);
PD>     display_data(&BIGGER_DATA, BIGGER_DATA.type);
PD> 
PD>    return(0);
PD> }
PD> 
PD> 
PD> I have tried to pass a void pointer to my function, but cannot
PD>access  individual members of the structure to perform comparisons.
If you can do what you want in the function with just one structure 
member, why do you need to pass the entire struct? Just pass the 
member. Or am I missing something in your question?
Cliff Rhodes
cliff.rhodes@juge.com
X CMPQwk 1.42 1692 X"Man's speech is like his life." - Plato
--- Maximus/2 3.01
---------------
* Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.