Click here to Skip to main content
15,886,873 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Glitch Pin
Viktor Signaievskyi17-May-11 8:42
Viktor Signaievskyi17-May-11 8:42 
GeneralRe: Glitch Pin
walterhevedeich17-May-11 14:53
professionalwalterhevedeich17-May-11 14:53 
GeneralRe: Glitch Pin
Viktor Signaievskyi18-May-11 7:48
Viktor Signaievskyi18-May-11 7:48 
GeneralRe: Glitch Pin
Chris Berger16-May-11 5:19
Chris Berger16-May-11 5:19 
GeneralRe: Glitch Pin
saxenaabhi616-May-11 20:31
saxenaabhi616-May-11 20:31 
GeneralRe: Glitch Pin
Viktor Signaievskyi17-May-11 8:59
Viktor Signaievskyi17-May-11 8:59 
GeneralRe: Glitch Pin
TorstenFrings17-May-11 2:39
TorstenFrings17-May-11 2:39 
GeneralRe: Glitch Pin
Viktor Signaievskyi17-May-11 9:31
Viktor Signaievskyi17-May-11 9:31 
I've made some kind of mistake Frown | :( "Copypasting" is evil Smile | :) . As MSDN ( http://msdn.microsoft.com/en-us/library/398ax69y.aspx ) claims, rand() function returns a pseudorandom integer in the range 0 to RAND_MAX (32767). So, the preferable way is to use the following "working code":

#define REALLYTRUE 1
#define REALLYFALSE 0
#define TRUE (rand() > (32762/2) ? REALLYTRUE : REALLYFALSE) // happy debugging losers

P.S. If to compile this code:
#define TRUE (rand() > 0.1 ? TRUE : FALSE) // happy debugging losers
we will have an error like:
c:\temp\win32\randex\randex.cpp(19) : error C2065: 'TRUE' : undeclared identifier
But using the new version of code it will be "all right" Laugh | :laugh:
GeneralRe: Glitch Pin
Stefan_Lang18-May-11 6:41
Stefan_Lang18-May-11 6:41 
GeneralThere is no Spoon Pin
AspDotNetDev13-May-11 12:17
protectorAspDotNetDev13-May-11 12:17 
JokeRe: There is no Spoon Pin
StM0n13-May-11 20:36
StM0n13-May-11 20:36 
JokeRe: There is no Spoon Pin
Sander Rossel13-May-11 22:30
professionalSander Rossel13-May-11 22:30 
GeneralRe: There is no Spoon Pin
Luc Pattyn14-May-11 2:12
sitebuilderLuc Pattyn14-May-11 2:12 
GeneralRe: There is no Spoon Pin
fjdiewornncalwe16-May-11 12:10
professionalfjdiewornncalwe16-May-11 12:10 
GeneralComparison and goto Pin
OriginalGriff13-May-11 9:28
mveOriginalGriff13-May-11 9:28 
GeneralRe: Comparison and goto Pin
Fabio V Silva13-May-11 9:46
Fabio V Silva13-May-11 9:46 
GeneralRe: Comparison and goto Pin
OriginalGriff13-May-11 21:03
mveOriginalGriff13-May-11 21:03 
GeneralRe: Comparison and goto Pin
Sander Rossel13-May-11 22:25
professionalSander Rossel13-May-11 22:25 
GeneralRe: Comparison and goto Pin
BillW3316-May-11 3:28
professionalBillW3316-May-11 3:28 
GeneralRe: Comparison and goto Pin
Shameel18-May-11 2:00
professionalShameel18-May-11 2:00 
GeneralRe: Comparison and goto Pin
H.Brydon20-May-11 8:24
professionalH.Brydon20-May-11 8:24 
GeneralMay be bad code or May not be!!! PinPopular
Ravi Sant12-May-11 0:57
Ravi Sant12-May-11 0:57 
GeneralRe: May be bad code or May not be!!! Pin
henrikqwerty32112-May-11 1:43
henrikqwerty32112-May-11 1:43 
GeneralRe: May be bad code or May not be!!! Pin
Daniel Scott12-May-11 2:43
Daniel Scott12-May-11 2:43 
GeneralRe: May be bad code or May not be!!! Pin
Luc Pattyn12-May-11 4:14
sitebuilderLuc Pattyn12-May-11 4:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.