- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
My favorite example of someone not understanding C strings was:
The coder told me that with sprintf() you needed to put a \0 at the end of the format string or else the output buffer would not be properly terminated. Only sprintf() works in this manner.Admin
You know, we've been seeing a lot of these misuse-of-string WTFs lately. Don't you just wish that someone would write a wrapper for all of the nastyness of manipulating them, so inept programmers could just use it instead of having to try (and fail) to reinvent the wheel?
Admin
Where's the fun in just using the wheel? We want to invent it! :)
At least, that's the prevailing attitude in newb programmers that have not yet seen the light.
Admin
The fun thing is that nobody's asked HOW the person expected strcat(buffer, '\0') to work if the terminating NULL wasn't already there. strcat needs the end of the string in order to append something to it.
Admin
So what? x and y can point to the same string at compile-time. z is not resolved until run-time since tmp is a variable, not a constant.
Yes, its true that z can be optimized at compile-time. But that's only really useful in languages where variables are pre-declared (C or Pascal). C#, C++, & Java can declare string types after executable statements.
Admin
What?! I do it all the time!
Crap, guess I got kind of overeager with the incrementing numbers... should have looked it over before posting it. There is some big irony in that somewhere...
Admin
Admin
The "Next>>" link is still broken :-/
Assuming you fixed up the comparisons in the if statements, this function is only useful if ERR_STRING_TOO_LONG is defined as 42.
Admin
I think there should be some XML somewhere in that code, or else it won't be enterprisey enough.
Admin
captcha: vern
Admin
Admin
Fancy seeing you here ;)
Admin
actually in windoz sometimes an extra null is required for some api calls e.g. OpenFileDialog
Admin
Ah yes, that's a series of null-seperated strings terminated by a double-null, isn't it? (The Windows API is fun!)
Admin
<sigh> You know it's time to finish for the day when the first thing you think when reading this is 'You don't need the "if (true)"'
Admin
Quite clever really...
(for any n00bs - wrap this with <JOKE> tags liberally.)
Admin
Uh ... didn't ANYONE notice that the malloc made the buffer one character too small, causing a guaranteed buffer overrun?
At least someone noticed the mixing of malloc and delete, and the confusion between "delete" and "delete []".
(Edit: wtf? the 'didn't ANYONE' line is after the close quote tag. Why is it in the box? Look at the page source.)
Admin
Come on, extra nulls in memory can help. This reminds me of programming back in school. Sometimes you could get a program to run after the fith or sixth attempt at executing it. That was because I filled RAM up with enough mis-placed \0s that I eventually got one in the right place :)
Admin
UNOPTIMISED.isPossible(EMBEDDED).DefaultValue = false;