FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » simple session question
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: simple session question [message #175761 is a reply to message #175758] Sun, 23 October 2011 16:18 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
Thomas Mlynarczyk wrote:
> The Natural Philosopher schrieb:
>> Forget the foo=foo++ and consider the cases
>>
>> bar=foo++;
>> and
>> bar=(foo++).
>>
>> In C they give different results.
>
> Interesting. If I remember correctly, ++ has higher precedence than = in
> C as well. Therefore, I would assume that both statements above are the
> same. Assuming foo = 0, bar should equal 0 in both cases and foo = 1.
>
> But you seem to imply that bar = (foo++) is identical to bar = ++foo? In
> that case I would find it very confusing.
>

Odd. It doesn't do it for bar, but it does if foo=(foo++);

cat test.c
#include <stdio.h>
main()
{
int foo,bar;
foo=0;
bar=(foo++);
printf("%d\n",bar);
}
$ make test
cc test.c -o test
$./test
0

--------------------

$ cat test.c
#include <stdio.h>
main()
{
int foo,bar;
foo=0;
foo=(foo++);
printf("%d\n",foo);
}
$ make test
cc test.c -o test
$ ./test
1

Looks like its stepping off into 'indeterminate behaviour'
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: session cookie: client side
Next Topic: by get this format my explode file name like this through php
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 07 23:09:16 GMT 2024

Total time taken to generate the page: 0.06149 seconds