• lulz (unregistered) in reply to aswefawfsadfafe
    No, the WTF is that he used href="#", which if you're not at the top of the page, will reset your page to the top.

    There are two correct ways of handling the onclick event:

    do do

    Of course, #2 doesn't work in IE, so really #1 is your only real choice until MS blows up and dies.

    That is because #2 is wrong way to do it. "javascript:" is used in href attribute, because its default type is URL, not javascript statement.

  • lulz (unregistered) in reply to lulz

    Alex,

    Would it be possible to change the server software to something less retarded than this "community server".

  • chriseyre2000 (unregistered) in reply to WTF Batman

    <a href="#" onclick="location='http://www.sun.com'; return false;">

    The above could also be an attempt to keep spiders away from the link

  • Nand (unregistered)

    The KSH example is pretty standart for shell scripts, especially if you don't spend all day writing them.


    From an older expr(1) manual page (2002)

    EXAMPLES
    1. The following example adds one to the variable a.
    a=expr $a + 1




  • Jim Burger (unregistered) in reply to mister r

    What exactly is so difficult about strcmp? There is a perfectly good reason for it to return the values that it does, even if its not used by 90% of the developers out there.

    Its ANSI definition states that it returns the lexicographical relation between two strings in the form of an integer. It doesn't return random values above or below zero - although I guess it could seem that way sometimes.Its fiendishly simple to remember when you've read and understood the docs for strcmp, the return value being the lexicographical *difference* between the two strings. http://www.cplusplus.com/ref/cstring/strcmp.html if the strings arent different then 0 is returned.

    The real WTF is still
    #define false 1
    #define true 0

    Maybe there should be a site entitled www.thedailyevilgenius.com >:->

     

  • (cs) in reply to Nand
    Anonymous:
    The KSH example is pretty standart for shell scripts, especially if you don't spend all day writing them.


    From an older expr(1) manual page (2002)

    EXAMPLES
    1. The following example adds one to the variable a.
    a=`expr $a + 1`




    I tested it on my linux box, expr is 60x slower than $(()) or let. But in many cases, it doesn't matter.
  • (cs) in reply to Russ
    Russ:
    Actually, I reckon this is from code that heavily used the strcmp family of functions - they return 0 if two strings are equal, so you end up with a lot of code like if(strcmp(str1, str2) == 0) all over the place (yes, I know you shouldn't use strcmp anyway, but bear with me). These funky defines would let you write if(strcmp(str1, str2) == true) which is slightly more readable - at the expense of making the rest of your code an impenetrable nightmare.

    Hmpf, I used to type if (!strcmp(str1, str2)) { } to check for same-ness of strings!

  • (cs) in reply to witch
    witch:
    Russ:
    Actually, I reckon this is from code that heavily used the strcmp family of functions - they return 0 if two strings are equal, so you end up with a lot of code like if(strcmp(str1, str2) == 0) all over the place (yes, I know you shouldn't use strcmp anyway, but bear with me). These funky defines would let you write if(strcmp(str1, str2) == true) which is slightly more readable - at the expense of making the rest of your code an impenetrable nightmare.

    Hmpf, I used to type if (!strcmp(str1, str2)) { } to check for same-ness of strings!



    So did I. Anyway, if I cared that much about the readability of string comparison, I'd rather define
    #define strequal(x,y) (!strcmp(x,y))
    than this idiotic true=0 stuff
  • kon (unregistered)

    some shells also support "let", not sure if ksh does.

    like: let foo+=1; or let foo++;

  • LucH (unregistered) in reply to Pinguis
    Anonymous:
    sh -- notice its sh not bash -- does this:

    echo $((1+1))
    2

    so the portability issues dont matter. that said, the expr version, is the one recomened by the man page. I assume this was a bash programer forced to use ksh? Remember that ksh inst free (beer of freedom).

    Probably because your are using an avanced shell. sh under Sun Solaris refuses this syntax. ksh and bash have no issues with it though.
    In plain sh, "bc" and "dc" can be used as alternatives --external programs-- to "expr".
  • LucH (unregistered) in reply to LucH
    LucH:
    Probably because your are using an avanced shell. sh under Sun Solaris refuses this syntax. [...]

    Of course /usr/xpg4/bin/sh has no troubles with $(())
  • (cs)

    Hmmm... Frankly I'm a bit disappointed with this WTF, but perhaps I've gotten a bit blunted from previous posts (WTFs AND replies...). Hope to see something REALLY WTF-ish later today (or in the morning perhaps) :)

  • (cs) in reply to lulz
    Anonymous:
    Alex,

    Would it be possible to change the server software to something less retarded than this "community server".


    Holy shit! You don't like the forum software?!

    Well, since no one else has complained about it, why should Alex just change it just for you? Anyway if he did change it, it would cut the post count in half.

  • (cs)
    Alex Papadimoulis:
    The next two lines of code took Christophe Beugnet hours and hours to correct. Who would have guessed that a supplier would have modified a header with this?

    <FONT color=#000099>#define</FONT> false 1
    <FONT color=#000099>#define</FONT> true 0

     

    This is the definition of justifiable homicide.

    Since I know nothing about Linux/Unix, I showed this next snippet of korn script (from Simmoril)to a Linux guy. He thought it was worth posting and said it was one of the more inventive ways to increment a variable. Anyone care to explain why?

    #!/bin/ksh 
    

    [... ommitting unimportant code...]

    export SLEEP_COUNT=expr $SLEEP_COUNT + 1

    Basically it's having to spawn a whole new process just to add 1 to SLEEP_COUNT, as opposed to just typing

    let SLEEP_COUNT=SLEEP_COUNT+1
    export SLEEP_COUNT
    

    or

    ((SLEEP_COUNT=SLEEP_COUNT+1))
    export SLEEP_COUNT
    

    which has the virtue of not incurring a context switch...

  • Chris (unregistered) in reply to DSx

    This is obviously security thru obscurity, he figured that nobody will ever figure out the 'real' password is, since he is 'transforming' it in the program. DOH!

    </sarcasm>

  • mister r (unregistered) in reply to An apprentice
    Anonymous:
    Anonymous:
    Which in itself is another WTF: that you can't overload operators and have functions that dispatch based on the types or their arguments. In haskell the quicksort function below, obviously also works for strings, but do you see a stringCompare anywhere?

    That's all well and good, but does Haskell support ternary logic {True, False, FileNotFound}? If not, then it's unusable in real life projects.



    Sure. If you really want to do that:

      data Ternary = True | False | FileNotFound

    But the FileNotFound thingie really should be more like an exception that an actual usefull return value. So you would abstract that shit away seperately:

       data CouldThrowAnException a = WentOk a | WentWrong String

    And the Boolean & Exception together would just be:

       type MyFileOperation = CouldThrowAnException Bool

    The function that should return your ternary state could read like:

       return (WentOk theFileIsPornFlag)

    Or, if it fails:

       return (WentWrong "File Not Found. So the answer is 7")

    Excuse the extreme names, but in examples like these they put some context to what we're doing. In Haskell, all these types are off course already standard, but called a bit different:

       data Either a b = Left a | Right b
       data Bool          = True  | False

    So then our type would just be:

       type MyFileOperation = Either Bool String
      
    .. and we would create constructor functions ourselves:

       wentOk :: Bool -> MyFileOperation
       wentOk b = Left b

       wentWrong :: String -> MyFileOperation
       wentWrong errMsg = Right errMsg

    .. which you could also also define as function aliases:

       wentOk       = Left
       wentWrong = Right

    Much cleaner than 'ternary' logic, if you ask me. And good usage of type and function aliases prevents the need for most low-level comments. Oh, and it makes any error message during compilation much much more readable.

      "a FileOperation was expected here, but a DbOperator was given"

    is much more readable than:

      "a (Either Bool String) was expected here, but a (Either Query String) was given"

    Hmm .. im getting off topic here. sorry. I suddenly recall that Ternary logic was actually a featured wtf... 

  • Zygo Blaxell (unregistered)
    Alex Papadimoulis:


    The "SLEEP_COUNT=`expr $SLEEP_COUNT + 1`" is fairly normal Unixese, if you want to guarantee that the script will run on any Unix since the early 1980's.  OTOH, if that were true, then neither "#!/bin/ksh" nor "export SLEEP_COUNT=..." would work.

    Back then, you needed to run an external program to do math in a script, but you needed to run an external program to do everything except simple loops and if statements.  Some old-timers might argue that even the simple loops and if statements should have been done with external programs too, but that argument has long since been lost.

    Modern Unix-like systems (OK, really we're talking about Linux now) build the "expr" command into the shell itself, so that old code runs without actually spawning a separate program.  Then you have to worry if your /usr/bin/expr is compatible with what you get when you just run 'expr' from the shell...

    /bin/ksh is not a standard shell,  so it's not portable (every Unix capable of understanding "#!" has a /bin/sh, but not necessarily anything else).  There was once a time when "#!" wasn't supported either, back in the days when there was only one Unix shell.

    Old Bourne shells need two separate commands to define a variable and export it.  They can't combine the two into one command as above, you must write it like this:

      SLEEP_COUNT=something
      export SLEEP_COUNT

    The thing that worries me is that in order for an exported SLEEP_COUNT variable to be useful, it would have to recursively call itself, since environment variables in Unix only affect the current process and its children--it's not like DOS/Windows where setting an environment variable affects every (or at least many) process(es) on the system.  I suspect the "unimportant code" is in fact very important after all.
  • Alan Trick (unregistered) in reply to John Smallberries
    John Smallberries:
    Anonymous:
    Alex,

    Would it be possible to change the server software to something less retarded than this "community server".


    Holy shit! You don't like the forum software?!

    Well, since no one else has complained about it, why should Alex just change it just for you? Anyway if he did change it, it would cut the post count in half.


    I don't know what world you live in, but just about every time I read through one of these I find at least 1, and often more people complaining about the forum software. You'll also see malformed posts (with <'s and >'s) all over the place because of the lack of preview ability in favor of this horrid thing they call WYSIWYG.

    The post today about the messed up javascript link was particularly funny because it looks like exactly something I'd see on these forums. For example the smilies on the left just give me a javascript error and are completely useless. If I try to post, about have the time this text box screws up and dies on me (giving javascript errors all over the place)

    On top of that there's there the smilies which look like they were done in MS Paint by the Teletubies ( see the post icon, because the simily thing on the left is broken ).

  • Alan Trick (unregistered) in reply to Alan Trick

    oh, wait I didn't read John's post properly.

    Anyways, this forum is just one of the many reasons ASP.Net should never have existed.

  • (cs) in reply to OneFactor
    OneFactor:
    WTF Batman:
    Drakonite:

    &lt;a href="#" onclick="location='http://www.sun.com'; return false;"&gt;


    Ugh, unfortunatly I see that crap all the time. It just goes to show, web monkeys should NOT be considered programmers...
    I feel generous calling them monkeys.


    It also occurrs to me that this is one way to make sure javascript is turned on. I use NoScript in FireFox, and come across plenty of pages that use links like this to force you to enable JS. That, or they're just idiots.
    Very interesting theory about making sure javascript is on. Maybe this isn't a WTF after all...

    "Web monkeys", LOL! That's why "web designers" and "web programmers" are swear-words over here in Germany.

    Yeah, this isn't a WTF after all. It's like that web site saying "Don't visit me never ever again!". Developer, here's your sign (http://www.mistupid.com/people/page013.htm)!

    Torsten

  • Anonymous Bob (unregistered)
    Alex Papadimoulis:
    I suppose I'll wrap things up with this final snippet of code from Maximillian, who's predecessor...


    "whose", damn you, "whose".
  • (cs) in reply to Anonymous Bob
    Anonymous:
    Alex Papadimoulis:
    I suppose I'll wrap things up with this final snippet of code from Maximillian, who's predecessor...


    "whose", damn you, "whose".


    "Whose," damn you, "whose."
  • (cs) in reply to Maurits

    Bzzzt: "Whose", damn you, "whose".

    The , and . are punctuation for the whole sentence so are outside the quotation marks.

  • (cs) in reply to mister r
    Anonymous:
    Anonymous:
    It seems like overkill to me, but in the guy's defense, doesn't this prevent a potential spelling error? So, it's not a complete WTF, is it?


    lol. yeah he did it like that because he wanted all of his string constants to be type-checked. You could in theory go all the way with this:

       (new Sentence (
                  (new Person ("me")).toString(),
                  (new Verb ("want")).toString(),
                  (new Item ("money")).toString()
             )).toString();

    But thats just madness, if all you wanted was the string constrant "i want money".



    You're not using design patterns! You should replace your new Person() line with something more like this:

    new PersonFactory(Locale.getDefault()).createPerson(PersonConstants.FIRST_PERSON_SUBJECTIVE);

  • (cs) in reply to dave
    dave:
    Bzzzt: "Whose", damn you, "whose".

    The , and . are punctuation for the whole sentence so are outside the quotation marks.



    In British English, yes.
    In formal American English (whatever that is) the comma or period ALWAYS goes inside the quotes.

    But the British English method is gaining popularity in the US.

    http://en.wikipedia.org/wiki/Quotation_mark
    (in the Typographical Considerations section)

  • jani (unregistered) in reply to dave
    dave:
    2. Using the ` is so 1980s. Even raw bourne shell supported the $( ) for returning output from a subshell.

    Not under Solaris! This is a POSIX thing.
    echo $(echo foo)
    syntax error: `(' unexpected


    dave:
    Also, Bourne shell is not really the lowest common denominator anymore. I've never seen a Unix or Unix a like since the 1990s that doesn't support either ksh or bash.


    That is probably correct, but how do you know which is installed, and where it is located?

    The former problem cannot really be solved runtime in the same script, but it can be solved by a wrapper script firing off the correct script.

    The latter problem can be solved by our friend /usr/bin/env, which also happens to be installed on most modern Unixes -- even Solaris.

    So, assuming that you have two script bases; one that's POSIX compatible and can run under both ksh and bash, and one that's Solaris sh compatible, you can do something like this in the wrapper script:

    #!/bin/sh
    
    if env ksh -c exit 2>/dev/null
    then
        shell=`which ksh`
    elif env bash -c exit 2>/dev/null
    then
        shell=`which bash`
    else
        ./bourne-script.sh
        exit $?
    fi
    
    echo '#!$shell' > newscript.sh
    cat posix-script.sh >> newscript.sh
    
    ./script.sh
    exit $?
    

    HTH, HAND.

  • (cs)
    Alex Papadimoulis:
    #!/bin/ksh 
    

    [... ommitting unimportant code...]

    export SLEEP_COUNT=expr $SLEEP_COUNT + 1

    UPDATE: Jos, who apparently knows more about this than my Linux guy, explains: This is just the classic Bourne shell way of doing math. The Korn shell (and since then the Bourne Again shell) added the "let" statement that let you do math inline, but that was not available in the original shell. We still write many shell scripts with classic code constructs since they're bound to work on each and every Unix system on the planet. I should note that this is why I normally shy away from posting things I don't understand.

    IANAL, butt it seems a bit silly to explicity use ksh when writing a generic shell script.

    BTW, I'm having some problems with a script of my own:

    <FONT style="BACKGROUND-COLOR: #ffffff" face="Courier New" color=#000000 size=2>/home/sidiot/My\ Programs/$ cat WTF.sh                                  
    #!/bin/sh                                                               
    SLEEP_COUNT=0                                                           
    while [[ $1 != $SLEEP_COUNT ]]                                          
    do                                                                      
     wait 1                                                                 
     export SLEEP_COUNT=`expr $SLEEP_COUNT + 1`                             
    done                                                                    
    exit 0                                                                  
                                                                            
    </FONT><FONT face="Courier New" size=2><FONT face="Courier New" size=2><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>/home/sidiot/My\ Programs/$ alias wait=sleep                            
                                                                            
    </FONT><FONT face="Courier New" size=2><FONT face="Courier New" size=2><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>/home/sidiot/My\ Programs/$ chmod +x WTF.sh                             
                                                                            
    </FONT><FONT face="Courier New" size=2><FONT style="BACKGROUND-COLOR: #ffffff" face="Courier New" color=#000000 size=2>/home/sidiot/My\ Programs/$ alias sleep="echo $( ./WTF.sh ) > /dev/null"
    ./WTF.sh: line 5: wait: pid 1 is not a child of this shell              
    ./WTF.sh: line 5: wait: pid 1 is not a child of this shell              
    ./WTF.sh: line 5: wait: pid 1 is not a child of this shell              
    ./WTF.sh: line 5: wait: pid 1 is not a child of this shell              
    ./WTF...</FONT></FONT></FONT></FONT></FONT></FONT>

  • I'm an AC (unregistered) in reply to dave

    dave:
    Re: ksh stuff Right, the reasons why it's a WTF. Let's remind ourselves of the script: #!/bin/ksh 1. If this is on Unix (as opposed to a Unix-a-like) then this should be #!/usr/bin/ksh (all the big flavours of Unix soft link /bin to /usr/bin) so it wastes a file system look up. export SLEEP_COUNT=`expr $SLEEP_COUNT + 1` 2. Using the ` is so 1980s. Even raw bourne shell supported the $( ) for returning output from a subshell. 3. As it's Korn shell this can be done either by, SLEEP_COUNT=$(($SLEEP_COUNT + 1)), or by (( SLEEP_COUNT += 1 )). $(( )) is a builtin version of expr and (( )) is an alias to the builtin let. The technique used is a waste of a process. 4. Does the variable need to be exported? Exporting should only be used to make it available to any child processes, if you don't spawn any children, why bother? On the bash vs sh vs ksh vs ksh93 vs perl (evil evil language) there is no comparision: ksh88 or ksh93 + awk wins hands down. (Before you ask, bash screws up scope and the vi editing mode in bash blows goats; finally - look at the manual page for bash under bugs, then you should understand). Also, Bourne shell is not really the lowest common denominator anymore. I've never seen a Unix or Unix a like since the 1990s that doesn't support either ksh or bash.

    1) First off, I don't think most Linux distributions symlink /bin to /usr/bin. So you may be technically correct, but why intentionally break it on other *nix systems, just to gain 1 filesystem traversal? Actually spawning the shell is FAR more intensive that finding it anyway, so I highly doubt you save anything noticable. (Note: On the FC4 box I'm on now, /bin/sh is a symlink to /bin/bash, but /bin is NOT a symlink to /usr/bin (or the reverse)... most things in /bin are not symlinks, and if they are, it's only to other things in /bin. /usr/bin/sh and /usr/bin/bash don't exist at all. ksh is in /bin. My point is, filesystem locations are not always a given.)

    2) Agree completely. Backticks are the bane of debugging. If your system doesn't support $( ), you need a new system.

    3) The $(( )) math syntax exists in bash, too. Dunno how good it is in ksh, but in bash it's somewhat limited. Works for ++-type operations, but not for floating-point stuff. If you need more than $(( )) supports, the normal solution is to invoke bc. From your description, I'd guess ksh behaves similarly.

    4) Agreed- perhaps this script is actually sourced, rather than run? In which case, export affects the CURRENT shell, not just child process too.

    IIRC, the reason for relying on /bin/sh and not something more advanced (like ksh, bash, or perl), is that it should work without dependencies (the shell itself... obviously the script might have its own dependencies). Thus, it exists in /bin, not in /usr/bin... because /usr might not be mounted. Furthermore, IIRC it's position is guaranteed- it always exists as /bin/sh. Where is ksh? Where is bash? Depends on the system... sometimes /bin, sometimes /usr/bin, sometimes /usr/local/bin, sometimes /opt... Finding it isn't aways easy, either... whence? which? env? They won't always give the same answer... and where are THOSE programs anyway? /bin? /usr/bin? Builtin functions?

    Also, porting: ksh -> bash (or vice versa) is harder than sh -> bash/ksh. If you have a ksh script, you would have to spend some time getting it to run under something else. Sticking to a subset allows for more choices in the case that you later need more functionality. (This of course assumes you don't yet need the extra functionality. If you already do, well...). I mention this only because I've worked on this before... things like syntax and builtin functions are sometimes less obvious than one would think.

    I HAVE seen systems that either don't have ksh/bash/csh, or have them in odd, unexpected places. Sometimes it's just that the admin never installed them, or did it by hand rather than a supplied package. The point is that one of them almost certainly exists, but I can't guarantee WHICH one, or WHERE it is. So if portability matters, it pretty much has to be /bin/sh.

    Lastly, I can be pretty sure my successor will understand plain sh scripts. But maybe he won't immediately understand ksh ones because he always uses bash, or vice versa.

    Thus ends my treatise on why one should use /bin/sh and not ksh or bash without good reason.

  • (cs) in reply to I'm an AC
    Anonymous:
    1) First off, I don't think most Linux distributions symlink /bin to /usr/bin. So you may be technically correct, but why intentionally break it on other *nix systems, just to gain 1 filesystem traversal? Actually spawning the shell is FAR more intensive that finding it anyway, so I highly doubt you save anything noticable. (Note: On the FC4 box I'm on now, /bin/sh is a symlink to /bin/bash, but /bin is NOT a symlink to /usr/bin (or the reverse)... most things in /bin are not symlinks, and if they are, it's only to other things in /bin. /usr/bin/sh and /usr/bin/bash don't exist at all. ksh is in /bin. My point is, filesystem locations are not always a given.)

    Hence why I said Unix vs Unixlike - Linux != Unix - it is a clone of the OS, following an old file system standard which most flavours of Unix have long abandoned (e.g. /usr being used for applications instead of /opt, having a lot of superfluous directories in /).

    If you're following a standard (e.g. the SYSV standards or LSB) then you know where your executable is. If some systems break the standard, then they're wrong and should be fixed (look at Windows :-).

    3) The $(( )) math syntax exists in bash, too. Dunno how good it is in ksh, but in bash it's somewhat limited. Works for ++-type operations, but not for floating-point stuff. If you need more than $(( )) supports, the normal solution is to invoke bc. From your description, I'd guess ksh behaves similarly.

    ksh88 only supports integers, so this won't make much difference. I don't know about ksh93.

    IIRC, the reason for relying on /bin/sh and not something more advanced (like ksh, bash, or perl), is that it should work without dependencies (the shell itself... obviously the script might have its own dependencies). Thus, it exists in /bin, not in /usr/bin... because /usr might not be mounted. Furthermore, IIRC it's position is guaranteed- it always exists as /bin/sh. Where is ksh? Where is bash? Depends on the system... sometimes /bin, sometimes /usr/bin, sometimes /usr/local/bin, sometimes /opt... Finding it isn't aways easy, either... whence? which? env? They won't always give the same answer... and where are THOSE programs anyway? /bin? /usr/bin? Builtin functions?

    Feh, /bin is not needed - /sbin on Unix is intended for anything less than single user mode (anything higher, you know that /usr will be mounted).

    Also, porting: ksh -> bash (or vice versa) is harder than sh -> bash/ksh. If you have a ksh script, you would have to spend some time getting it to run under something else. Sticking to a subset allows for more choices in the case that you later need more functionality. (This of course assumes you don't yet need the extra functionality. If you already do, well...). I mention this only because I've worked on this before... things like syntax and builtin functions are sometimes less obvious than one would think.

    Again, the whole point of standards (our lovely POSIX standard). Fortunately bash nearly follows the standards, the only problem I've found 'twixt bash and ksh is due to the different ways that they handle scope. (Also bash's vi command line edit mode is very buggy.)

    Lastly, I can be pretty sure my successor will understand plain sh scripts. But maybe he won't immediately understand ksh ones because he always uses bash, or vice versa.

    One phrase: man ksh. sh/ksh/bash share a common pedigree, so the differences are slight, and good coding practice can minimise these.
    Using bourne shell is just crippling - why restrict yourself to bread when you can have venison? It's like insisting on using Windows 3.1 because you don't understand Windows 2003.

    I wouldn't get so wound up about it except for the times involve, bourne shell is older than me, korn shell was written in 1988 and updated in 1993, bash has been around since the early 90's. So, why are we still insisting on using something that is over 30 years old? This is one thing that Linux got right - use of bourne shell is treated as legacy and should be avoided.

  • woohoo (unregistered) in reply to Omnifarious
    Omnifarious:
    Alex Papadimoulis:

    I don't know why it's inventive. AFAIK, that's the way it has to be done in a shell script, unless it supports the $(( ... )) syntax, in which case you can do:

    export SLEEP_COUNT=$(( $SLEEP_COUNT + 1 ))

    Which isn't really that much smaller or more understandable.

    Better still:

    SLEEP_COUNT=$SLEEP_COUNT+1
    , but this is arguably not as portable as the 'expr' version.

  • Anon (unregistered) in reply to macronencer
    macronencer:
    You could try #define EQUAL 0 #define GREATERTHAN 1 #define LESSTHAN -1

    Only problem is that, IIRC, strcmp et al. don't guarantee to return particular absolute values - just that the return will be 0...

    The way strcmp() is meant to be used is to always compare its result explicitly against 0, i.e.

    strcmp(a, b) == 0 strcmp(a, b) < 0 strcmp(a, b) >= 0

    That way, when you see 'strcmp() op 0', just think 'a op b'...

    Those who haven't got it at this point never will.

Leave a comment on “A Friday Mixer”

Log In or post as a guest

Replying to comment #:

« Return to Article