- 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
So what does this CAPTCHPA thing mean on all the posts anyway? Is it a reference to some previous article or something?
Actually I might have just figured it out.
CAPTCHA: muhahaha
Admin
No.
Admin
How about using pSpaceChar as a "/t".
Like:
string Spacer(string a, string b, string c) {
int N = 8; //Set the width of the tab.
return a & pSpaceChar(N - len(a)) & b & pSpaceChar(N - len(b)) & c & pSpaceChar(N - len(c)); }
Just hope that a, b, and c are less than 8 characters long. Hell, you could even write a check for that. Hmm, how convoluted could that check be? Nested ifs? State machine?
Admin
I use a function (rather than array) to return X spaces to help with aligning columns in a console app. Not a very exciting use, I'm afraid.
Admin
Admin
How about it being a char * instead of a const char *, too? String literals are const char *'s.
Admin
the python language is famous for delimiting blocks by their indentation.
if you try to write a python interpreter in python, you might end up writing something like this:
this is the most innefficient way of finding indentation ever written on earth, but a fair use of the described technique...
Admin
I've been wondering about the captcha too...how do you add do your word, or do you just add it in your comment for the fun of it..
Admin
In C string literals have type char *, not const char *, you just aren't allowed to modify them.
Admin
The Captcha was waffles dammit.
Admin
It was my understanding that space was ever expanding. So pSpaceChar should not be a static array. It needs to be dynamic to account for more space.
Admin
Why, I use that exact code to display my Christmas tree every year!
Admin
How about using it as a multiplication teaching tool? You could also make some really gross uses of the old VB String function.
What's 5*5 kids? hmmm: String(5, pSpaceChar[5]) == String(25, " ")
Admin
Perhaps it could be used as part of a code generator for the Whitespace language. Something like Add being equivalent to pSpaceChar[2].
http://compsoc.dur.ac.uk/whitespace
Admin
Admin
Why not this?
Or:
Oh, I know, I know, not what we were looking for. We were looking for ways to use pSpaceChar.
Admin
The code is bugged. It should look that way:
Admin
Obviously, this only makes sense when combine with other WTFs.
Admin
Pfft - this needs to be migrated to a J2EE Platform.
I offer forth the WhiteSpaceGenerator! It's even thread-safe!
Admin
Hmm, 8 different strings... Surely this is some (even more!) esoteric dialect of brainfuck?
Admin
YOU WISH! (I'm pretty sure the standard CPython interpreter considers a \t to be equivalent to 8 spaces)
Admin
this one gets my vote so far.
Admin
Isn't it obvious! Someone is trying to create an octal calculator. Just define an array of char * pointers long enough to hold the number you want, and set each pointer to the relevant element in the spaces array. For example
char *Number1[MAXDIGITS] = {pSpaceChar[4], pSpaceChar[2], ""}; //024 char *Number2[MAXDIGITS] = {pSpaceChar[7], pSpaceChar[5], ""}; //057 char *Number3[MAXDIGITS] = {""};
Addition is performed by concatenation, followed by reducing the length by 8 & carrying pSpaceChar[1], if necessary.
Subtraction is just reverse addition. Other operators left up to the reader.
I'd go into more detail but lunch break is over.
Disclaimer: Hey - I wrote the code above quickly. Forgive any WTFs, please.
Admin
Perhaps this is used in source code generator for the Whitespace programming langauge.
Admin
Admin
Technically they are char[N]
Admin
i am a total tard and can't format comments. "this one gets my vote so far" should have been outside of the quote. kill me.
Admin
This is quite likely the drollest comment that has ever appeared here. Absolutely delightful!
Admin
The only combination of factors that could be attributed to this code:
Admin
char *pSpaceCount[8] = { ... " ", // One Space Character, AH AH AH! " ", // Two Space Characters, AH AH AH! " ", // Three Scintillating Space Characters, AH AH AH! ... };
Admin
As I think some commenters have been trying to say, this would be useful for converting tabs to spaces. 8-printPos%8 would give the number of spaces to add to go to the next tab after printPos (assuming printPos is positive, and you really want to go to the next tab if it is already at a tab), and instead of adding that number of spaces, just index into this array.
Not that it would save much time, but it isn't that much of a WTF if it is used that way.
Admin
TonyL,
Ha, I got that same forward just this morning. I thought the elephant one was hilarious also.
Admin
I guess they don't know about the %.*s printf format...
Admin
Well, perhaps I'm wtfing. I did this a couple months ago. (not global)
If I'm WTFing here, let me know. I personally thought it was better than what this was written to replace (which just put the dashes and spaces inline, repeated 600 times), but if there's a still better way, I'll be glad to hear it.
Other WTF's are probably evident from this code ("why not just write a formatting function?", "Those incrementing numbers.. are they for a purpose as stupid as they seem to be?", "What the hell is an RC00...? is that a named constant for a specific literal number??", "Why are you outputting what looks like C comments in the first place?", etc), but I'd like to think those aren't mine. The use of pSpaces/pDashes itself, I don't see a problem with.
As for using an array, that's just stupid. Were I to do what was being done in the supplied code, I'd probably go with something like:
Admin
You forgot to define MAYBE. I suggest:
MAYBE = "true"
Admin
The real WTF is the unreadability...
I think "5[pSpaceChar]" would be better readable than "pSpaceChar[5]";
Back to the example.. It's just a form of loop-unrolling... Defining often used data first... Classic optimisation :-)
Admin
pSpaceChar is the toilet.
Admin
Admin
Try re-reading my post, I said string literals couldn't be modified.
Admin
Admin
No, no, no...
The default case should return FILE_NOT_FOUND. Don't you people know ANYTHING about programming???
Admin
I'd say anyone who includes it would pass with a D+. Anyone who tries to make a clever quip about their captcha FAILS.
Captcha: Cognac. At this time of the morning?! It's is early but I guess I will drink some!! ROFL
Admin
I think the best use would be as an entry in a personnel file listing reasons for termination. You know, exceeded sick leave and doesn't show up for work, when he does show up he's drunk, and the following code. That way he doesn't get unemployment compensation.
Actually, I liked the Christmas Tree. If there's a prize, give it to him.
Admin
hah hah! Loved this one.
Admin
here's my captcha:
Admin
A construct like this:
can be used for any base 7 arithmetic that you might imagine. What we have defined for us here is a representation of the numbers 0 through 7 which is Octal. So I have written a decimal to octal converter...
My example in Java since my C is quite rusty...
... and no, I didn't test it. This is off the top of my head so YMMV. Need a new numerical base? Change the array definition. Use a HashMap for Hexidecimal.
--Zarf aka Foo
Admin
Admin
Admin
captcha: howdy - the rabbit says 'HOWDY'!
Admin