Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!lll-tis!mordor!sri-spam!rutgers!umn-d-ub!umn-cs!ems!rosevax!richw From: richw@rosevax.Rosemount.COM (Rich Wagenknecht) Newsgroups: comp.lang.c Subject: dynamic mem allocation for structures Message-ID: <3834@rosevax.Rosemount.COM> Date: 7 Jan 88 14:30:14 GMT Organization: Rosemount Inc., Eden Prairie, MN Lines: 26 Keywords: MS,C,structures Assuming I have a structure like: struct junk { type element1; type element2; } (The elements in the structure are not important.) And I have a pointer: struct junk *junk_ptr; How do I type cast my void pointer from malloc? The following doesn't seem to work. junk_ptr = (struct junk *)malloc( sizeof(struct junk)); Is the above statement possible? If not, any suggestions? Thanks for your help, -- Rich W richw@rosevax.Rosemount.COM Disclaimer: My views may not represent my own much less my employer's.