From: deadlyhead <deadlyhead@gmail.com>
Subject: Re: Access to C_float wipes out float value
Date: Thu, 19 Aug 2010 19:12:13 -0700 (PDT)
Date: 2010-08-19T19:12:13-07:00 [thread overview]
Message-ID: <f48f7776-ea36-4b70-a461-8b312167a8fc@q40g2000prg.googlegroups.com> (raw)
In-Reply-To: op.vhpr9cmzxmjfy8@garhos
On Aug 19, 7:09 pm, Yannick Duchêne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
> Le Fri, 20 Aug 2010 03:40:18 +0200, deadlyhead <deadlyh...@gmail.com> a
> écrit:
>
>
>
> > void*
> > do_something (int get_float)
> > {
>
> > int* i;
> > float* f;
>
> > int in = 12345; // <<< local
> > float fl = 9876.54321; // idem
>
> > f = &fl; // <<< reference to local
> > i = ∈ // idem
>
> > if (!get_float) {
> > printf ("Value of \"*i\" is %d\n", *i);
> > return i; // <<< return reference to local
> > } else {
> > printf ("Value of \"*f\" is %f\n", *f);
> > return f; // idem
> > }
> > }
>
> Did you really want to return a reference to a local variable ? Are you
> sure ?
Ah, thank you. I didn't even think of that.
prev parent reply other threads:[~2010-08-20 2:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-20 1:40 Access to C_float wipes out float value deadlyhead
2010-08-20 2:05 ` (see below)
2010-08-20 2:09 ` Yannick Duchêne (Hibou57)
2010-08-20 2:12 ` deadlyhead [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox