bloggins02
Programmer
Hi everyone <br><br>Bear with me here I'm teaching myself C as I go. I would like to be able to send different types of structs accross a network using the same function. I don't have a problem breaking the structs down and send()ing them, but I tried this and it doesn't work:<br><br>int send_struct(int fd, void *input_struct, int struct_type)<br>{<br> switch (struct_type) {<br> case THIS_TYPE_OF_STRUCT:<br> do_this(fd, (struct this_type) <br> input_struct->member);<br> break;<br> case THAT_TYPE_OF_STRUCT:<br> do_that(fd, (struct that_type)<br> input_struct->member);<br> break;<br>}<br><br>Of course when I compile this little "gem of brilliant coding" I get a "member is not part of a structure or union" and I also get "warning: attempt to dereference a void pointer". I know I've got the all wrong here. What do I need to do to implement this? Is it even possible?<br><br>Thanks a lot guys!