| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
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 |
|
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? |
|
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.
|
Expand(string expression) {
inspiration:
|
|
How about it being a char * instead of a const char *, too? String literals are const char *'s.
|
|
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... |
Re: Global Spaces
2007-02-16 09:20
•
by
BunnyStrider
(unregistered)
|
|
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..
|
|
In C string literals have type char *, not const char *, you just aren't allowed to modify them.
|
|
The Captcha was *waffles* dammit.
|
|
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.
|
|
Why, I use that exact code to display my Christmas tree every year!
|
|
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, " ") |
|
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 |
|
|
Why not this?
sprintf(pDuration, "%-*s", pPointer, ((9 - iLength) * 2) + strlen(pPointer)); Or: sprintf(pDuration, "%*s%s", " ", (9-iLength) * 2, pPointer); Oh, I know, I know, not what we were looking for. We were looking for ways to use pSpaceChar. |
Re: Global Spaces
2007-02-16 09:42
•
by
Anonymous coward
(unregistered)
|
|
The code is bugged. It should look that way:
char *pSpaceChar[8] = {
|
|
Obviously, this only makes sense when combine with other WTFs.
|
|
Pfft - this needs to be migrated to a J2EE Platform.
I offer forth the WhiteSpaceGenerator! It's even thread-safe!
|
|
Hmm, 8 different strings... Surely this is some (even more!) esoteric dialect of brainfuck?
|
HAH! YOU WISH! (I'm pretty sure the standard CPython interpreter considers a \t to be equivalent to 8 spaces) |
this one gets my vote so far. |
|
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. |
|
Perhaps this is used in source code generator for the Whitespace programming langauge.
|
Re: Global Spaces
2007-02-16 10:01
•
by
newt0311
(unregistered)
|
no, char * are perfectly modifiable. Its done all the time. all that a char * means is an array of characters and is the closest C comes to a string. a const char * is also a valid declaration which will cause the compiler to raise an error if any attempt is made to modify it. gcc also gives a warning when a const is assigned to a non-const without a specific declaration to go along with it. |
|
Technically they are char[N]
|
|
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.
|
This is quite likely the drollest comment that has ever appeared here. Absolutely delightful! |
|
The only combination of factors that could be attributed to this code:
1. Very specifically formatted outputs 2. Poor understanding of a language 3. Slight intellectual impairment or alcohol |
|
char *pSpaceCount[8] = {
... " ", // One Space Character, AH AH AH! " ", // Two Space Characters, AH AH AH! " ", // Three Scintillating Space Characters, AH AH AH! ... }; |
|
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. |
|
TonyL,
Ha, I got that same forward just this morning. I thought the elephant one was hilarious also. |
|
I guess they don't know about the %.*s printf format...
|
|
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:
|
Re: Global Spaces
2007-02-16 10:28
•
by
HappyPanda
(unregistered)
|
You forgot to define MAYBE. I suggest: MAYBE = "true" |
|
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 :-) |
|
pSpaceChar is the toilet.
|
But Rob was talking about string literals, which are often in read-only memory (irrespective of what the type decorations say...) |
Try re-reading my post, I said *string literals* couldn't be modified. |
It's an intelligence test. Anyone who includes their captcha in their post, fails. |
Re: Global Spaces
2007-02-16 10:47
•
by
BitTwiddler
(unregistered)
|
|
No, no, no...
The default case should return FILE_NOT_FOUND. Don't you people know ANYTHING about programming??? |
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 |
|
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. |
|
hah hah! Loved this one.
|
|
here's my captcha:
/´¯/) ,/¯ / / / /´¯/' '/´¯¯·¸ /'/ / / /¨¨/¯\ ('( ´ ´ ¯ ;/' ') \ ' / '\' \ _.·´ \ ( \ \ |
|
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 |
|
|
captcha: howdy - the rabbit says 'HOWDY'! |
static char *sevenSpaces = " "; |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |