Click here to Skip to main content
16,011,868 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: SQL query - which version do you prefer? Pin
Vasudevan Deepak Kumar6-Nov-07 23:49
Vasudevan Deepak Kumar6-Nov-07 23:49 
GeneralAssignment [modified] Pin
Jim Warburton5-Nov-07 6:39
Jim Warburton5-Nov-07 6:39 
GeneralRe: Assignment Pin
James R. Twine5-Nov-07 6:45
James R. Twine5-Nov-07 6:45 
GeneralRe: Assignment Pin
leppie5-Nov-07 8:23
leppie5-Nov-07 8:23 
GeneralRe: Assignment Pin
James R. Twine5-Nov-07 12:00
James R. Twine5-Nov-07 12:00 
GeneralRe: Assignment Pin
Chris Meech5-Nov-07 8:55
Chris Meech5-Nov-07 8:55 
GeneralRe: Assignment Pin
KarstenK8-Nov-07 2:59
mveKarstenK8-Nov-07 2:59 
GeneralRe: Assignment Pin
Tomas Brennan19-Nov-07 4:53
Tomas Brennan19-Nov-07 4:53 
Uhh....loooks like you've forgotten 1 extra for NUL terminated char...

text = (char*)malloc(sizeof(char) * (seven + 1));

And also...check for NULL if this fails...my c skills are a bit rusty so excuse if I trip up, from what I can remember this nice terse statement which was favourite of mine..

if (!(text = (char*)malloc(sizeof(char) * (seven+1)))){
...mem is gud...
}else{
...phffft...
}

this is a nice lil exercise since I used to program in C professionally, then switched over to C# cos the skillset was dwindling in the IT sector here in Ireland... not sure why you'd free the pointer though...I think that you'll have garbage in text_store.title...I could be way off here on this...

Take care,

Tom

#define STOOPID
#if STOOPID
Console.WriteLine("I'm stoopid!");
#endif

GeneralFor loop horror Pin
Llasus1-Nov-07 14:12
Llasus1-Nov-07 14:12 
GeneralRe: For loop horror Pin
Marc Clifton1-Nov-07 15:35
mvaMarc Clifton1-Nov-07 15:35 
GeneralRe: For loop horror Pin
Anton Afanasyev1-Nov-07 19:59
Anton Afanasyev1-Nov-07 19:59 
GeneralRe: For loop horror Pin
Christopher Duncan2-Nov-07 4:17
Christopher Duncan2-Nov-07 4:17 
GeneralRe: For loop horror Pin
Dan Neely2-Nov-07 4:57
Dan Neely2-Nov-07 4:57 
GeneralRe: For loop horror Pin
Luc Pattyn1-Nov-07 16:06
sitebuilderLuc Pattyn1-Nov-07 16:06 
GeneralRe: For loop horror Pin
cp98761-Nov-07 20:53
cp98761-Nov-07 20:53 
GeneralRe: For loop horror Pin
jhwurmbach2-Nov-07 5:44
jhwurmbach2-Nov-07 5:44 
GeneralRe: For loop horror Pin
Stephen Hewitt1-Nov-07 20:44
Stephen Hewitt1-Nov-07 20:44 
GeneralRe: For loop horror Pin
Llasus4-Nov-07 14:22
Llasus4-Nov-07 14:22 
GeneralRe: For loop horror Pin
Brady Kelly1-Nov-07 22:50
Brady Kelly1-Nov-07 22:50 
GeneralRe: For loop horror Pin
Chris Maunder2-Nov-07 4:02
cofounderChris Maunder2-Nov-07 4:02 
GeneralRe: For loop horror Pin
Nitron2-Nov-07 4:13
Nitron2-Nov-07 4:13 
GeneralRe: For loop horror Pin
Chris Losinger2-Nov-07 6:01
professionalChris Losinger2-Nov-07 6:01 
GeneralRe: For loop horror Pin
emiaj2-Nov-07 6:50
emiaj2-Nov-07 6:50 
GeneralRe: For loop horror Pin
Thea Ganoe2-Nov-07 8:46
Thea Ganoe2-Nov-07 8:46 
GeneralRe: For loop horror Pin
Llasus4-Nov-07 14:20
Llasus4-Nov-07 14:20 

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.