Comment On Who's Hard-Core Now?

Let me tell you, as a Visual Basic enthusiast it really pains me that so many of the posts here are in my programming language of choice. So whenever I post something from another language, I usually let out a little smirk. But today I'm beyond smirking. Oh yes, it's gloating time! [expand full text]
« PrevPage 1 | Page 2Next »

Re: Who's Hard-Core Now?

2005-01-18 17:18 • by Maurits
I don't know what kind of self-respecting C programmer uses double-parentheses ((when single will do))

Re: Who's Hard-Core Now?

2005-01-18 17:20 • by Goudinov
I think there's a secret message hidden in that code...

Re: Who's Hard-Core Now?

2005-01-18 17:22 • by
This is one of the times I actually said WTF out loud (well, the full phrase).

Re: Who's Hard-Core Now?

2005-01-18 17:24 • by
28050 in reply to 28046
for (i=0,j=0;iswitch(buff[i]) {


case '+':


value[j] = ' ';


buff[i] = ' ';


break;


case '%':



You can't nest case statements in a for loop.

Re: Who's Hard-Core Now?

2005-01-18 17:32 • by AndrewVos

hahahhhahaha!!!! BLIND!


thanks for reminding me how much i hate C. last time i really hated it was when i had to convert a C funtion to vb.net, and there were no comments at all!!!!!! kill this language now!!!! move over to vb!!!!!!!! (btw if u could use copper wires it would probably make it much easier!!!)

Re: Who's Hard-Core Now?

2005-01-18 17:35 • by AndrewVos
28052 in reply to 28051
BTW well done bro, this is the funniest site i've ever seen, been coming home and checking my rss for the new WTF's! some ppl are soooo stupid! anyways, tnx for the free laughs!

Re: Who's Hard-Core Now?

2005-01-18 17:35 • by
28053 in reply to 28050
You can't nest case statements in a for loop.


There's a problem in the HTML. View source and you'll see that it's supposed to say:

for (i=0,j=0;i<strlen(buff);i++,j++)
switch
{
case '+':

etc

Re: Who's Hard-Core Now?

2005-01-18 17:47 • by
oy! it gets worse:

for (i=0,j=0;i
strlen is O(N) for the length of the buffer, effectively turning this into an O(N^2) algorithm. I'd say it's C written with a VB accent.

Re: Who's Hard-Core Now?

2005-01-18 17:50 • by
28056 in reply to 28050

Of course you can't, but I expect someone would know that '<' is the open tag for html elements so all text after that point until the next tag hasn't been displayed :)


for(i=0,j=0;i<STRLEN(BUFF);I++,J++)


switch

Re: Who's Hard-Core Now?

2005-01-18 18:23 • by
begin(pedantry):

seems Alex got a little overexcited when posting.. and stated that this
was an "ASCII to HEX function".. and unless I'm missing something it is
indeed quite the opposite

end



Although I must say these things lose some of their impact when they repetitive bits are snipped out :) still a good laugh.



And just to add some balance to all these silly comments about C being
evil, or VB being evil for that matter: Get over it, on both/all sides.
Languages for problems, any sufficiently stupid person can write
utterly horrific code in any language. The worst cases in some
languages are perhaps wors than those in others, just as the most
elegent solution for a given problem in one language might be more
elegent than the same in another. (or the most efficient, or short, or
readable, etc)



(Don't have an account, but I'm David)

Re: Who's Hard-Core Now?

2005-01-18 18:37 • by Razzie
I hope he gets paid per line of code. Or wait. I don't. Oh nevermind.

Re: Who's Hard-Core Now?

2005-01-18 18:53 • by kentcb
28059 in reply to 28058
WTF! A VB programmer coding in C! ;)

Re: Who's Hard-Core Now?

2005-01-18 19:18 • by
Yeah, this totally looks like a VB programmer trying to write in C.

Re: Who's Hard-Core Now?

2005-01-18 20:00 • by
I am disturbed by seeing ugly stuff like this in the beautiful C-language.



Maybe this kind of stuff should be censored when it's in C, and only
shown when written in VB (or BASIC V2.0?), so you won't be responsible
for making people like me depressed. I feel this WTF is intrusive, and
i feel that my personal life and even my will to live has been
compromised.



It is unresposible to publish stuff like this on an open forum, and the
poster clearly have not considered the consequenses it could have. To
prevent any serious injury in the future (maybe some people will kill
themself when seeing this), i'm planning to sue the owner of this
website.

Re: Who's Hard-Core Now?

2005-01-18 20:24 • by Son of Guayo
ah, but when you use the correct compiler and the correct optimizer
flags and pray to the correct deity, this code actually compiles to the
fastest, most optimized, least memory hungry binary.

Re: Who's Hard-Core Now?

2005-01-18 20:27 • by foxyshadis
The full file isn't quite the full file. It's just the section that's
posted. Even though I'm sure I could reconstruct it, I want to see it
for myself!



Talk about your massively unrolled loop.

Re: Who's Hard-Core Now?

2005-01-18 21:04 • by

Please now, let us not condem an entire programming language because some idiot doesn't know how to use it.


Here is a more reasonable and concise "hard core" bit of 'C' code to ponder...


If you're really "hard core", you'll probably recognize the following code snippet as Duff's Device. Otherwise, you'll probably not be able to figure out what it does, or how.


   register n = (count + 7) / 8;      /* count > 0 assumed */
   switch (count % 8)
   {
   case 0:        do {  *to = *from++;
   case 7:              *to = *from++;
   case 6:              *to = *from++;
   case 5:              *to = *from++;
   case 4:              *to = *from++;
   case 3:              *to = *from++;
   case 2:              *to = *from++;
   case 1:              *to = *from++;
                      } while (--n > 0);
   }

Re: Who's Hard-Core Now?

2005-01-18 21:05 • by foxyshadis
28067 in reply to 28064
Son of Guayo:
ah, but when you use the correct compiler and the correct optimizer
flags and pray to the correct deity, this code actually compiles to the
fastest, most optimized, least memory hungry binary.





Haha. *sob* I would advise you to take a class in assembly language, to avoid becoming a WTF yourself in the future. ;p



It used to be that with a well-written C program you could compile down
to vector jumps with switch statements and judicious use of registers.
To be honest I don't know how it would be done in these days of huge
caches and long pipelines, but what I have seen is usually just
extrapolations on the theme.



Not... this. Eek.



I take your point that a compiler could refactor this whole pile into
one tiny, tight routine. Except that compiler doesn't exist, and if it
did we'd all write shitty code because the compiler'd always clean it
up for us. It will, a little, but this is whole levels of shitty beyond
that.

Re: Who's Hard-Core Now?

2005-01-19 01:33 • by Drak
28071 in reply to 28057

:
And just to add some balance to all these silly comments about C being evil, or VB being evil for that matter: Get over it, on both/all sides. Languages for problems, any sufficiently stupid person can write utterly horrific code in any language. The worst cases in some languages are perhaps wors than those in others, just as the most elegent solution for a given problem in one language might be more elegent than the same in another. (or the most efficient, or short, or readable, etc)

(Don't have an account, but I'm David)


I have to agree with David (get an account!! [:)]). I have used both C (and C++ for that matter) and VB (and VB.Net too), and both have their charms.


If I need something really quickly I will use VB.Net, as it's less likely to break with fast, unverified programming.


I will also be trying some C# this year I think, just to see how that flows.


Drak

Re: Who's Hard-Core Now?

2005-01-19 02:32 • by phx
28072 in reply to 28071

C# flows very nicely. I used to favour C++, but now i get the convenience of C# (which is about as convenient as VB.Net). When you need to do something more "traditional" (eg: some fun pointer arithmetic to piss off some auditors - modulus based ring buffers are easily hidden) you can use unchecked { ... } blocks for allowing overflow, and unsafe { ... } blocks for use of pointers and other "fun".


Theres also some other classes and statements for dealing with pointers safely in normal code. unsafe/unchecked blocks require full security permission to execute (for obvious reasons).


Also my C# tip of 2004: The sealed modifier is used to prevent inheritance of a class. What is undocumented is that sealed can also be used as a modifier to a function, preventing overrides of just that function.

Re: Who's Hard-Core Now?

2005-01-19 02:32 • by
28073 in reply to 28066
What's the point? It seems to me that the effect can be archieved in more readable and as fast/faster code.

Re: Who's Hard-Core Now?

2005-01-19 04:19 • by im_not_jose
wow, VB coder with a chip on his shoulder. [8-|]

Re: Who's Hard-Core Now?

2005-01-19 04:25 • by
28077 in reply to 28063

:
It is unresposible to publish stuff like this on an open forum


UNRESPONSIBLE? What kind of word is that? Irresponsible please! That's the problem with you C-type programmers, lack of communication skills.


A humble VB programmer with a penchant for [the English] language.

Re: Who's Hard-Core Now?

2005-01-19 04:27 • by im_not_jose
28078 in reply to 28076
hehe... vb and c, good for various things, but usually crap if you are trying to do the same thing.



i stick to C/C++, because I feel it looks a bit better on the resume
and if the topic ever arised, I would rather impress an interviewer
with knowledge of something OOD.



but nowadays, the gap is being bridged, 'specially with VB.NET and
C#... is there any difference? they are both compiled into MS IL
anyways, just a difference coding preference



but you would have to admit, C++ is slightly better than VB, although
the difference is not great in many respects, but its often harder to
learn to be a good C coder/

Re: Who's Hard-Core Now?

2005-01-19 05:27 • by phx

Would the following C++ crap be considered a more concise and ugly method? I'm hoping it works, and assuming in, out are char* and len is the length of in. I'm even nice and allocating the output buffer :D

[code language="c#"]

#define hexdig(c) (c>9)?:('0'+c):(56+c)
out=alloc(2*len);
for(i=0;i<len;i++)
{
 out[2*i]=hexdig(in[i]&15);
 out[2*i+1]=hexdig(in[i]&240);
}

[/code]

Notes:
('A'+c-9) is too much code, so i use (56+c)

Re: Who's Hard-Core Now?

2005-01-19 05:28 • by phx
28080 in reply to 28079

Spot the extra bloody colon.

Re: Who's Hard-Core Now?

2005-01-19 05:52 • by KoFFiE
28081 in reply to 28077
:

:
It is unresposible to publish stuff like this on an open forum


UNRESPONSIBLE? What kind of word is that? Irresponsible please! That's the problem with you C-type programmers, lack of communication skills.


A humble VB programmer with a penchant for [the English] language.



Don't forget that a lot of ppl that visit this site don't have English as their native language (i.e. me [:)])




Anyway - nice piece of code... Guy really should learn:

1) What a string is in C

2) What "hex" is

3) What "ascii" is

4) What "binary" is

5) What "strcat" & "strncat" do

6) What pointers are


I am really amazed that he already knows the "safe" strncpy function, although he still uses the normal strcpy sometimes... (and no - this is no defending of the code [:D])



For the ppl that say the compiler can optimize this -ERR- wrong [:)] strcmp is a function from some library, the C compiler doesn't know what it does, so it can't optimize string comparisons - it's not a language construct as in many other languages.

At least C-compilers are smart enough to generate code that stops evaluating all conditions when || (logical OR) is used and a "true" condition is met somewhere in it (VB doesn't do this, it always evaluates everything) - but still, every loop where a '%' is encountered will trigger a _LOT_ of strcmp's.



This site should really organize a contest or smth - rewrite the pieces of code published here in the most optimal way in the same language... Would be fun too see the results... [:D]



PS: The formatting in of these replies really sucks... Half-my-ass HTML and some wannabe BB-code? Wrote a nice parser for the latter - but well - it's C eeh... I mean PHP [:D] [;)]

Re: Who's Hard-Core Now?

2005-01-19 06:21 • by Bellinghman
strg[k] = ' ';
strg[k+1] = 'C';
strg[k+2] = 'o';
strg[k+3] = 'p';
strg[k+4] = 'y';
strg[k+5] = 'r';
strg[k+6] = 'i';
strg[k+7] = 'g';
strg[k+8] = 'h';
strg[k+9] = 't';
strg[k+10] = ' ';

This is just so delightful. strncpy(strg, " Copyright ", 11) would have been so much more concise, and much more readable.


I'm not even going to comment on the rest. It's just too painfully obvious that this isn't a native C coder.

Re: Who's Hard-Core Now?

2005-01-19 06:29 • by Bellinghman
28084 in reply to 28081

For the ppl that say the compiler can optimize this -ERR- wrong Smile strcmp is a function from some library, the C compiler doesn't know what it does, so it can't optimize string comparisons - it's not a language construct as in many other languages


Since it's part of the standard C library, the compiler is allowed to know what strcmp() does. And many compilers will actually replace the function call with the actual underlying code - for example, VC++ 6 will, if run with /Oi, inline strcmp().


PS: The formatting in of these replies really sucks... Half-my-ass HTML and some wannabe BB-code? Wrote a nice parser for the latter - but well - it's C eeh... I mean PHP Big Smile Wink


Ah, yes. I actually fire up IE for this forum, since the handling under any normal browser is so bad. When place like LiveJournal can get formatting right, and actually understand threading, using phpBB is a bigger WTF than any code yet posted.

Re: Who's Hard-Core Now?

2005-01-19 06:50 • by KoFFiE
28085 in reply to 28079
phx:

Would the following C++ crap be considered a more concise and ugly method? I'm hoping it works, and assuming in, out are char* and len is the length of in. I'm even nice and allocating the output buffer :D

[code language="c#"]

#define hexdig(c) (c>9)?:('0'+c):(56+c)
out=alloc(2*len);
for(i=0;i<len;i++)
{
 out[2*i]=hexdig(in[i]&15);
 out[2*i+1]=hexdig(in[i]&240);
}

[/code]

Notes:
('A'+c-9) is too much code, so i use (56+c)



This would not be correct... The ('A'+c-9) should at least be ('A' + c - 10), and the compiler optimizes this anyway - so no need to make your code less clear :)
Also, you start with the wrong nibble, and you don't shift it with 4 bytes...



Code below works (both way algorithms)



[code language="c#"]

#define HEX_CHAR(c) ( ((c <= '9') && (c >= '0')) ? (c - '0') : ( ((c >= 'A') && (c <= 'F')) ? (c - 'A' + 10) : -1) )
#define HEX_DIGIT(c) ( ( (c) < 0x0A) ? ('0' + (c)) : ('A' + (c) - 10) )

long hex2long(char *str)
{
long lng = 0;
int tmp;
while ( (*str) && ( (tmp = HEX_CHAR(*str)) >= 0) ) {
lng = (lng << 4) | (tmp&0x0F); // shift 4 bit
str++;
}
return lng;
}

char *dumpHex(char *in, int len)
{
char *tmp, *out;
int i;

if (len < 0) len = strlen(in);
out = malloc( (2*len) + 1); // spacer for end '\0'
tmp = out;

for(i = 0; i < len; i++) {
*tmp = HEX_DIGIT( (in[i] >> 4) & 0x0F ); tmp++;
*tmp = HEX_DIGIT(in[i] & 0x0F); tmp++;
}
*tmp = '\0';

//printf("HEX:\n%s", out);
//free(out);
return out; // free it yourself function -> dangerous!! :)
}

[/code]

Re: Who's Hard-Core Now?

2005-01-19 07:01 • by

I left the best out: After posting the code to Alex i found this code right after the hex to ascii conversion:


out = popen(SENDMAIL_PATH,"w");
fprintf(out,"From: xxxx\n");
fprintf(out,"To: xxxxx\n");
fprintf(out,"Subject: Feedback-Error\n\n");
fprintf(out,"Hexcode [%s] ist dem Programm nicht bekannt!\n\n",hexstr);
pclose(out);
kontaktformular = "nein";
show_error("../../fehler/feedback/index.html","<br>Es ist ein Fehler aufgetreten und direkt an unsere Technik weitergeleitet worden!<br><br>Bitte versuchen Sie es später noch einmal.<br>");
exit(1);

Re: Who's Hard-Core Now?

2005-01-19 07:38 • by Bellinghman
KoFFiE:







 Bellinghman wrote:






Since it's part of the standard C library, the compiler is allowed to know what strcmp() does. And many compilers will actually replace the function call with the actual underlying code - for example, VC++ 6 will, if run with /Oi, inline strcmp().



Inlining is a rather simple method to optimize something. Optimizing by predicting what will happen is something completely different, and extremely complicated, certainly if you start doing this on strings...



Indeed. However, trying to optimise round a function call is extremely difficult. If the code can pull the content of the function call inline, then it can (not necessarily will) be able to do a much better job. It need no longer push registers that the function never overwrote anyway. Register colouring can work. If it works really, [li] really hard, it might throw away stuff that turns out not to be required.


(Though I think it's on a hiding to nothing with this code.)


As far as the strings thing is concerned - well, all the compariosons are against short fixed strings. There is a chance that the intrinsic code could actually just do two byte comparisons rather than a loop.


Still, the original code is a total mess. I'd recommend the author look at 'Unicode Demystified' . It contains code that addresses much more complex requirements, with much simpler code, and it might inspire him to write C, rather than VB using C syntax.

Re: Who's Hard-Core Now?

2005-01-19 07:39 • by sas
Just because some doofus managed to convert his VB script into compilable C, it doesn't make him a C programmer.  [:P]



Dead giveaway: "j = j + 2;"?  wtf?  That's like wearing women's underwear.  [:$]



Anyway, I think the maximum wtf density is attained in the 256-clause if statement that is a tautology.  [:@]



I can't stand to read any more. [+o(]

Re: Who's Hard-Core Now?

2005-01-19 07:42 • by phx
28091 in reply to 28085

KoFFiE:


you don't shift it with 4 bytes...



Probably the dumbest part...


I can see myself debugging that for hours and not noticing too ;)

Re: Who's Hard-Core Now?

2005-01-19 10:00 • by DavidM
28095 in reply to 28066

:

Please now, let us not condem an entire programming language because some idiot doesn't know how to use it.


Agreed ...


:

If you're really "hard core", you'll probably recognize the following code snippet as Duff's Device.


Well, this all depends on how you define "hard core". I presume Duff's Device is one of those old C chestnuts that a certain breed of C programmer takes great pleasure in discussing? That must make me not "hard core". Oh well.


:

Otherwise, you'll probably not be able to figure out what it does, or how.


Speak for yourself (whoever you are, "anonymous"). I agree that it looks confusing, but it doesn't take that long to work out. If this code compiles, then this must mean that the switch/case statements aren't treated by a C compiler as a construct in the same way the do ... while is. The do ... while compiles independently of the switch/case, and the switch/case is then interpreted as a jump into a particular position in that compiled code - this makes sense, given the default fall through behaviour of C. The switch statement is executed only once, meaning that the first run through the loop is only partial. Given that the address of the destination (to) isn't incremented in the way that the address of the source (from) is, it is probably some kind of serial device. So the net result is that count values are copied from memory starting at location from, to a serial device of some description. I presume they are copied in blocks of eight (first block may be less than eight to give exactly count values overall) for performance reasons?

Re: Who's Hard-Core Now?

2005-01-19 10:32 • by fluffy
28097 in reply to 28084
Bellinghman:

For the ppl that say the compiler can optimize this -ERR- wrong Smile strcmp is a function from some library, the C compiler doesn't know what it does, so it can't optimize string comparisons - it's not a language construct as in many other languages


Since it's part of the standard C library, the compiler is allowed to know what strcmp() does. And many compilers will actually replace the function call with the actual underlying code - for example, VC++ 6 will, if run with /Oi, inline strcmp().


PS: The formatting in of these replies really sucks... Half-my-ass HTML and some wannabe BB-code? Wrote a nice parser for the latter - but well - it's C eeh... I mean PHP Big Smile Wink


Ah, yes. I actually fire up IE for this forum, since the handling under any normal browser is so bad. When place like LiveJournal can get formatting right, and actually understand threading, using phpBB is a bigger WTF than any code yet posted.

Re: Who's Hard-Core Now?

2005-01-19 10:33 • by fluffy
28099 in reply to 28097
grr, fucking piece of shit forum software.



This isn't phpBB.  phpBB doesn't suck NEARLY this bad. 
Actually I rather like phpBB, after making a few simple modifications
to it anyway.



Anyway, this is written in ASP, not PHP.  That should be your first clue that this isn't phpBB.

Re: Who's Hard-Core Now?

2005-01-19 10:57 • by Drak
28100 in reply to 28099

Actually its in ASPX. The .Net variant of ASP. Which in itself means nothing as the editing control is javascript/vbscript I guess.


Drak

Re: Who's Hard-Core Now?

2005-01-19 11:21 • by

Let me tell you, as a Visual Basic enthusiast it really pains me that so many of the posts here are in my programming language of choice.


The reason most bad code is in Visual Basic, is because most of all code is in Visual Basic.


"To the first approximation" all programmers are VB programmers.  All other languages are in the noise level (or as they put in on "The West Wing" last week "within the margin of error...of not having any support at all")


 

Re: Who's Hard-Core Now?

2005-01-19 11:23 • by JamesCurran
28104 in reply to 28102

Booger...Anonymous again.   That last one was me.


Isn't this site supposed to auto-logon?

Re: Who's Hard-Core Now?

2005-01-19 11:24 • by brandonh6k
Get the IEView extension for Firefox.  It will save you a ton of
frustration with this forum.  You only need to use IE if you're
quoting though. [:)]

Re: Who's Hard-Core Now?

2005-01-19 11:25 • by Bellinghman
28106 in reply to 28099

fluffy:
grr, fucking piece of shit forum software.

This isn't phpBB.  phpBB doesn't suck NEARLY this bad.  Actually I rather like phpBB, after making a few simple modifications to it anyway.

Anyway, this is written in ASP, not PHP.  That should be your first clue that this isn't phpBB.


Ah, thanks for the clarification. I'd ended up trying to find out what the heck BB was (it's very briefly mentioned, with no explanation in the site FAQ) and arrived at the phpBB pages. I then made the assumption that this was using that.


I have a friend who works for a certain very large company that happen to run, among other things, a certain two web applications.. One is driven by Python. The other by ASP. One is incredibly successful, and always responsive. The other is godawful slow. They're looking to rewrite the ASP one into Python.


And yes, you probably use one of them frequently.

Re: Who's Hard-Core Now?

2005-01-19 11:46 • by
DavidM,
you're on target about Duff's Device. Efficiency is why it does the
"blocks of eight" thing with the mod-eight part done first: That way,
it only has to check to see if it's done on every eighth byte.



The
best part about the strncpy() issue is that in the two places where he
*should* be using strncpy() but isn't, he *is* using strncpy() for
essentially the same thing, on the line immediately preceeding the
horrible unrolled gunk.



Between that, and "i = i + 2", and a few other items (not least the 256
case sensitive strcmp()s instead of two isxdigit()s), and strcmp()ing
"25" etc. when he should've strtol()'d the string once and switched on
the integer) -- this poor guy is not a C programmer.



Re: Who's Hard-Core Now?

2005-01-19 12:43 • by Stan Rogers
28113 in reply to 28111
That's a wild assumption. Could be that everything this person ever did
was in C, and that all the training he/she ever got was from one of
those "teach yourself C in an afternoon" books. This snippet could as
easily be a small sampling of hundreds of megabytes of equally-bad
source code.



Not a competent C programmer? No. Not a good C programmer? Definitely
not. Not a C programmer? Not enough data to draw a conclusion.

Re: Who's Hard-Core Now?

2005-01-19 12:50 • by Drak
28114 in reply to 28113

You can add 'Not a competent programmer' to that list, and leave out the C. Anyone with some feeling and competence for/in programming could think of a better way to do this, regardless of the language they program in.


Drak

Re: Who's Hard-Core Now?

2005-01-19 12:53 • by
Alex Papadimoulis:

It's even worse than the Worst Possible VB Solution. And it's in C!





The language has nothing to do with crappy code.

Re: Who's Hard-Core Now?

2005-01-19 15:21 • by ArmchairDissident@mac.com
28129 in reply to 28050
:
You can't nest case statements in a for loop.



You can. You may not want to - but you can:


void main()
{
int i;
int count = 10; /* or any arbitrary value */
switch(count)
{
case 0: for(i = 0; i< 20; i++){
case 1: count ++;
case 2: count++;
case 3: count++;
}
}
}


Compiles and works just fine. It's the same as Duff's device mentioned elsewhere just - probably - not as useful. Remember that a switch{ case: } construct is just a structured "goto" in C.

Re: Who's Hard-Core Now?

2005-01-19 15:25 • by Irrelevant
Duff's Device

Basically, it's loop unrolling (as done by any optimising compiler),
which means the repeat condition gets checked less often, and there are
less code jumps for the same number of iterations. It only works if you
know how many times it's looping beforehand, but it can make a big
difference if the repeated operation is small and done a lot of times
(as in here).

Re: Who's Hard-Core Now?

2005-01-19 16:47 • by
28139 in reply to 28050

:
for (i=0,j=0;iswitch(buff[i]) {
case '+':
value[j] = ' ';
buff[i] = ' ';
break;
case '%':

You can't nest case statements in a for loop.


 


It's just badly posted, look at the C source at the end of the post to see the correct version.


It seems this code attempts to change some string into a verbal form of some sort

Re: Who's Hard-Core Now?

2005-01-19 17:00 • by

ArmchairDissident, I think that's not what he meant. There was a left

angle bracket in the for loop header, which resulted in the following:



for (i=0,j=0;iswitch(buff[i]) {

    //...the horror, the horror...

}





Notice

where it says "iswitch" -- that "i" should be followed by a less-than,

and then the rest of the line. The HTML formatting script screwed up. Among

other things, the for's close-paren and opening curly brace are

missing, as well as a newline. In the original code the switch was not inside the for-loop header. But that reader

mistakenly thought otherwie.s



You are, of course, correct about arbitrary case placement and Duff's Device.





Allow me to say, by the way, that this commenting software is

staggeringly, mind-numbingly bad. It's ass to use, it enforces bizarre,

difficult-to-read font choices, and it fills the comments page with

meaningless and distracting visual noise. The person or persons who

designed it were criminally incompetent. No slightest thought was given

to usability or utility. There is more to good interface design than

spraying brightly-colored crap around the screen.

« PrevPage 1 | Page 2Next »

Add Comment