From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Access to C_float wipes out float value
Date: Fri, 20 Aug 2010 04:09:02 +0200
Date: 2010-08-20T04:09:02+02:00 [thread overview]
Message-ID: <op.vhpr9cmzxmjfy8@garhos> (raw)
In-Reply-To: e42a0d91-535b-4f75-8ae6-58238a51d84c@x24g2000pro.googlegroups.com
Le Fri, 20 Aug 2010 03:40:18 +0200, deadlyhead <deadlyhead@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 ?
next prev parent reply other threads:[~2010-08-20 2:09 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) [this message]
2010-08-20 2:12 ` deadlyhead
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox