From: Ron Michael Khu <ronkhu@ntsp.nec.co.jp>
To: Vadiraj <vadiraj.cs@gmail.com>
Cc: linux-c-programming <linux-c-programming@vger.kernel.org>
Subject: Re: ternary operator
Date: Wed, 29 Jun 2005 01:44:30 +0800 [thread overview]
Message-ID: <42C18C7E.6030100@hq.ntsp.nec.co.jp> (raw)
In-Reply-To: <6eee1c405062810224f4db7e5@mail.gmail.com>
i dont know the reason but the problem could be shrink down to
func2()
{
}
func1()
{
printf( "%d\n", func2() );
}
int main()
{
printf( "%d\n", func2() );
printf("%d\n",func1() ) ;
}
u will notice that the return value from func2(which does not specify
any explicit return value)
differs when called from main() and from func1()..
this is not a problem about the ternary operator..
this is an issue about the use of implicit/explicit return values...
why are u not making use of explicit return? and explicit use of int as
the return type in the
function declarations??
Vadiraj wrote:
>Hi List,
>
> I'm confused with the behavior of this program..
>
>func4()
>{
> return 3;
>}
>func3()
>{
> return 2;
>}
>func2()
>{
>}
>
>func1()
>{
> return(func2()?func3():func4()) ;
>}
>int main()
>{
>
> printf("%d\n",func1() ) ; // this prints 3
> printf("%d\n",func2()?func3():func4()) ; // this prints 2
>}
>
> I dont understand whats making the two statements to behave differently.
>
>
>
>
>
next prev parent reply other threads:[~2005-06-28 17:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-28 17:22 ternary operator Vadiraj
2005-06-28 17:44 ` Ron Michael Khu [this message]
2005-06-28 17:49 ` Steve Graegert
2005-06-28 17:15 ` Luiz Fernando Capitulino
2005-06-28 18:24 ` Steve Graegert
2005-06-28 18:24 ` Vadiraj
2005-06-28 18:47 ` Steve Graegert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42C18C7E.6030100@hq.ntsp.nec.co.jp \
--to=ronkhu@ntsp.nec.co.jp \
--cc=linux-c-programming@vger.kernel.org \
--cc=vadiraj.cs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).