Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ucsd!usc!zaphod.mps.ohio-state.edu!rpi!crdgw1!underdog!volpe From: volpe@underdog.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: Casting pointers Keywords: cast Message-ID: <9959@crdgw1.crd.ge.com> Date: 19 Jul 90 13:45:49 GMT References: <1614@ghost.stsci.edu> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@underdog.crd.ge.com (Christopher R Volpe) Lines: 26 In article <1614@ghost.stsci.edu>, davids@stsci.EDU (David Silberberg) writes: |>If the last line above were replaced by |> |> ptr = (char *)ptr + num_chars; |> |>it would perform as desired. Does casting work on an lvalue? I'm not sure if casting on an l-value is specified anywhere. (Never seen it in K&R.) But it sometimes does bizarre things. Consider the following code: main() { int i; float f; f=2.0; (float) i = f; printf("i==%d\n",i); } Compiled with Sun C, this program prints: i==1073741824 Compiled with gcc, it prints i==2 Chris Volpe