Hi,
I have such code:
Can anyone explan what does this operator <?= do?Code:for(int i=0;i++<limit; maxx <?= rt + tt) { ... }
Thanks.
Hi,
I have such code:
Can anyone explan what does this operator <?= do?Code:for(int i=0;i++<limit; maxx <?= rt + tt) { ... }
Thanks.
I don't think that's valid code. (Although it might be a digraph I don't know about.)
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Well, I compiled it and it works fine.
Regards.
Ah! I know! <? is !. So <?= is the same as !=.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Thanks, is there any reason of using something like that ?
Obfuscation perhaps..Originally Posted by apacz
There are contests to have the most obscure code, or simply to have the most obsure code (encrypted so it couldnt be understood )
Last edited by Dae; 09-24-2005 at 03:20 PM.
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
Sweetie, '?' is the ternary operator, otherwise known as the conditional operator. It's called 'ternary' because it works with THREE operands...unlike something like '+' which works with two: (x+y).
This is the alternative to if/else statements: it reads: "If x > y, assign x's value to z. Else, assign z the value of y."Code:int x=2, y=5, z=0; //Our three operands z = (x > y) ? (x:y); //Assign z to the bigger one.
How does that work in the situation its being used here?
if maxx is 0, assign it to rt + tt? I'm confused already.Code:maxx <?= rt + tt
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
How does that work in the situation its being used here?
if maxx is 0, assign it to rt + tt? I'm confused already.Code:maxx <?= rt + tt
It cant be != like dwks said though, because its in the third section of the for statement..
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
<? is described as a trigraph. The purpose of trigraphs is to allow programmers to work with keyboards that do not support certain characters. Most common scenario is on keyboards designed for non-english speakers (eg Scandinavian languages) <? expands to an exclamation mark (!)
Last edited by grumpy; 09-24-2005 at 04:16 PM.
In this case it is indeed a digraph take means !
However it is not defined in the standard so use at your own risk.
>>However it is not defined in the standard so use at your own risk.
ok mom.
why is everyone so anal about standard code?
his own risk? a bit harsh a word considering all he wanted to know what what it meant.
Ya, i'm just a bit annoyed right now at everyone harrassing me about "why are you writing it that way."
Clear the mines from our Shazbot!
Get the enemy Shazbot!
Because not everyone in the world uses the same compiler or OS. By following the standard you help ensure that the program will run as intended regardless of the machine. Of course there are times when the standard has to go out the window to solve a problem. However the likelyhood of someone posting a question on this board in which that would be the case is pretty slim.Originally Posted by jrahhali
Now how about you tell me why you think you shouldn't follow the standard?
Edit: Also about getting annoyed about people asking why you did something a certain way: Get used to it. You should be confident enough to explain exactly why you did something a particular way. And that doesn't go just for programming but for all areas of your work. When I worked as a switchboard tech I was asked quite regularly how I came to a conclusion and why I went with a particular path for solving the problem.
>>Now how about you tell me why you think you shouldn't follow the standard?
But for his purposes, he wanted to know what it meant.
edit: nvm..nvm. bye.
Clear the mines from our Shazbot!
Get the enemy Shazbot!
When people say "use at your own" it doesnt just mean the OP, its anyone reading this to know that information. Also he is using that code apparently, and if using <? is unsafe I'm sure you would want to at least know.
Anyway, question... what exactly the purpose of the third statement in this for loop?
Its not even in the condition statement.Code:for(int i = 0; i++ < limit; maxx != rt + tt) { ... }
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101