Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!orion.oac.uci.edu!uci-ics!megatek!hollen From: hollen@megatek.UUCP (Dion Hollenbeck) Newsgroups: comp.lang.c Subject: Re: Assigning an address to an integer Message-ID: <486@tau.megatek.uucp> Date: 1 Jun 90 19:16:34 GMT References: <1280003@hpcc01.HP.COM> Organization: Megatek Corporation, San Diego, Ca. Lines: 26 From article <1280003@hpcc01.HP.COM>, by azarian@hpcc01.HP.COM (Randy Azarian): > Can I assign an address of a variable to the value of a standard integer? > { > int a,d; > a=&d; > bdos(1,a,1); > } > This works, but gives me the following warning: > warning C4047: '=' : different levels of indirection You can get rid of the problem by casting it: a = (int)&d ; We do this all the time when passing addresses as "magic cookies". We obtain them and do the cast. They are then stored as ints and passed around as ints. When they finally get to the function which needs them, they are cast back to a pointer of the proper type. -- Dion Hollenbeck (619) 455-5590 x2814 Megatek Corporation, 9645 Scranton Road, San Diego, CA 92121 uunet!megatek!hollen or hollen@megatek.uucp