Columnists' WTF





  • Wow.



    Let me start by answering the first question:


    1. How large is a pointer?

      Pretty big. I mean, it has to reach all the way from where you are
      in memory to where the object is in memory, and that can be over
      4billion bytes long in some cases.



    2. How do you write strcpy?

      Very simple:



      int i;



      for(i = i; i < strlen(s1); i++);

      {

          s2[i] = s1[i];

          i = i+1; // If you need to copy strings 11 bytes at a time, see TDWTF.

      }



      Yea, that should do it.



    3. How do you implement an infinite loop?



      My, my. This is a tricky one, but I have a sure fire way to a correct solution, Just count to infinity in increments of 11.



      #define INFINITY (1/0)

      while(i < INFINITY)

      {

          i = increment_by_11(i);

      }




  • 1. How big is a pointer?

    Answer: My index finger is about 3.75 inches long. Would you like to see the middle finger?

    2. How do you write strcpy?

    Answer: I'm left handed, and I prefer using a black ballpoint pen.

    3. How do you implement an infinite loop?

    Answer: Rather than pretend to misinterpret your question, I'll beat you over the head with...oh, what do I have laying around here... a stapler and a can of compressed air. An infinite loop is when the program starts doing something and *NEVER* stops. Infinite loops should be AVOIDED, not IMPLEMENTED. You should have your computer privileges revoked immediately. Someone call the proper authorities.



  • @Bellinghman said:

    Snort. That's got to be one of the most
    densely WTFed bits of code I've seen in ages. I adore the O(N^2) time
    to execute. I love the way it'll start at a random position. I love the
    way it'll copy every other character. I even find it cute the way it'll
    not bother terminating the target string.




    Yeah, originally, I started with a while loop, and actually
    initializing the variable, but decided that was wayyy too close to
    correct. A nice extra touch is that it does absolutely nothing but
    waste time. (Look closely at the for statement....)



  • And at the risk of straying my own thread off topic...

    ... would it have been ethical for a reputed author/editor to deliberately answer wrongly to teach students a lesson to do their own homework?



  • @icelava said:

    ... would it have been ethical for a reputed author/editor to deliberately answer wrongly to teach students a lesson to do their own homework?




    Fun? Yes. Ethical? No. The ethical thing to do is to ignore the
    question and move on to the next, or respond with "Do your own
    homework, please!"



    Even if they get what they deserve, it still doesn't make it right.




  • Thank you for the affirmation.



  • @Bellinghman said:

    Mike R: "(Look closely at the for statement....)" Erk - oh yes. I can only spot a certain density of bugs-per-inch before my brain shuts down and mentally rewrites the code from scratch. Your example surpassed it.

    I did the same thing.  I missed the i = i  [:D]



  • @cm5400 said:

    @Bellinghman said:

    Mike R: "(Look
    closely at the for statement....)" Erk - oh yes. I can only spot a
    certain density of bugs-per-inch before my brain shuts down and
    mentally rewrites the code from scratch. Your example surpassed
    it.

    I did the same thing.  I missed the i = i  [:D]


    Did you see the semicolon after the for statement?


  • @sas said:

    @cm5400 said:

    @Bellinghman said:

    Mike R: "(Look
    closely at the for statement....)" Erk - oh yes. I can only spot a
    certain density of bugs-per-inch before my brain shuts down and
    mentally rewrites the code from scratch. Your example surpassed
    it.

    I did the same thing.  I missed the i = i  [:D]


    Did you see the semicolon after the for statement?


    mmm.. It was a thing of beauty... [:D]



  • Douglas Adams rulez :D Someone should write a Hitchhiker's Guide to IT one of these days...




  • @divVerent said:

    BTW: the movie was bad.




    It wasn't without its merits. I don't think it was nearly as great as
    the books. They messed with the plot a bit too much, though.



  • @sas said:

    @cm5400 said:

    @Bellinghman said:

    Mike R: "(Look closely at the for statement....)" Erk - oh yes. I can only spot a certain density of bugs-per-inch before my brain shuts down and mentally rewrites the code from scratch. Your example surpassed it.

    I did the same thing.  I missed the i = i  [:D]


    Did you see the semicolon after the for statement?

    Damn!, missed that one!  It's been awhile since I have programmed in C/C++, Java, C# etc.  I ususally use VB.NET.



  • @divVerent said:

    3. How do you implement an infinite loop?

    Just implement a loop which terminates with infinte improbability. And hope it never actually happens.

    BTW: the movie was bad.





    I think a better way would be to aim at implementing a loop which will terminate... and miss.



        -dZ.



  • God I'm depressed.  Here I am, brain the size of a planet, and all they can ask me is "How large is a pointer?" or "How do you implement an infinite loop?"  "Do my homework for me Marvin". 



  • Someone at least needs to post a functioning strcpy, so I thought I would.



    void strcpy(char *dest, char *src)

    {

        size_t len = strlen(src)+1;

        int prime = len+1;

        

        for (int i =2; ;++i) {

        if (prime % i ==0) {

            ++prime;

            i = 2;

        }

        if (prime > len && (i+1)==prime)

            break;

        }

        

        for (int i =1;i < prime; ++i) {

        dest[prime % i]=src[prime % i];

        }

    }




  • @Mike R said:



    1. How do you write strcpy?

      Very simple:



      int i;



      for(i = i; i < strlen(s1); i++);

      {

          s2[i] = s1[i];

          i = i+1; // If you need to copy strings 11 bytes at a time, see TDWTF.

      }




    Hi, Mike.



    I'm new to C++. Started to program för Symbian Series 60 in C++ this spring.

    Just an small School- project for developing an Calendar application.



    I have got the feeling that variable i shuld be set. There is nothing that states that it is 0.

    And i wonder why do you declare the variable before the if-statement?






  • @Generic said:



    Hi, Mike.



    I'm new to C++. Started to program för Symbian Series 60 in C++ this spring.

    Just an small School- project for developing an Calendar application.



    I have got the feeling that variable i shuld be set. There is nothing that states that it is 0.

    And i wonder why do you declare the variable before the if-statement?




    >>Crosses Fingers<< Please be joking. Please be joking. Please be joking.



  • @Mike R said:

    @Generic said:


    Hi, Mike.



    I'm new to C++. Started to program för Symbian Series 60 in C++ this spring.

    Just an small School- project for developing an Calendar application.



    I have got the feeling that variable i shuld be set. There is nothing that states that it is 0.

    And i wonder why do you declare the variable before the if-statement?




    >>Crosses Fingers<< Please be joking. Please be joking. Please be joking.




    Me like Mike. Mike is funny.

    But you did not answer my question. This makes Generic sad.

    Please make me happy by answering my question.



  • @Generic said:

    @Mike R said:
    @Generic said:


    Hi, Mike.



    I'm new to C++. Started to program för Symbian Series 60 in C++ this spring.

    Just an small School- project for developing an Calendar application.



    I have got the feeling that variable i shuld be set. There is nothing that states that it is 0.

    And i wonder why do you declare the variable before the if-statement?




    >>Crosses Fingers<< Please be joking. Please be joking. Please be joking.




    Me like Mike. Mike is funny.

    But you did not answer my question. This makes Generic sad.

    Please make me happy by answering my question.




    Okay, let me spell it out for you in explicit terms.



    Because the code was a joke. Why do you think the post was swimming in
    sarcasm? Did you bother to read the discussion after the post?
    Apparently not. It was never meant to be taken seriously, or even work.
    Generally if I plan on doing a for loop like that, I initialize the variable in the initialization segment of the for loop. i.e. for(int i = 0; i < n; i+=11) etc...



    Some terms you may be unfamiliar with:



    joke

    n.

    1. Something said or done to evoke laughter or amusement, especially an amusing story with a punch line.
    2. A mischievous trick; a prank.
    3. An amusing or ludicrous incident or situation.
    4. Informal.
      1. Something not to be taken seriously; a triviality: The accident was no joke.
      2. An object of amusement or laughter; a laughingstock: His loud tie was the joke of the office.

    See definition 1.

    sar·casm

    n.

    1. A cutting, often ironic remark intended to wound.
    2. A form of wit that is marked by the use of sarcastic language and is intended to make its victim the butt of contempt or ridicule.
    3. The use of sarcasm. See Synonyms at wit<font size="-1">1</font>.
    See definition 2.


  • @Mike R said:

    sar·casm
    n.

    1. A cutting, often ironic remark intended to wound.
    2. A form of wit that is marked by the use of sarcastic language and is intended to make its victim the butt of contempt or ridicule.
    3. The use of sarcasm. See Synonyms at wit<FONT size=-1>1</FONT>.

    See definition 2.

    Wooooo, an infinite loop:

    Sarcasm: The use of sarcasm

    Drak



  • Another example: the Jargon File definition for self-reference.

    (Confession: I did manage to implement an infinite loop once--the old classic "two functions calling each other" routine...)

    <FONT style="BACKGROUND-COLOR: #dbd9d1">Note: due to a compound WTF committed by the designers (the "post" button where normal forums have a "reply" button), me (hey, replying is a subset of posting...), and some unknown being (who has set <10 seconds as the time limit to edit one's post in this section), this reply also appears as its own topic. If someone wanders by who can delete it, please do (the other one, not this one!)</FONT>



  • Did you try clicking the link from the article to "implement an infinite loop" and clicking the first link. This currently gives a pretty good explanation of an infinite loop.



  • @j_johnso said:

    Did you try clicking the link from the article to "implement an infinite loop" and clicking the first link. This currently gives a pretty good explanation of an infinite loop.




    Ohh, man! If MSN ever had an "I'm feeling lucky" button.



  • @Mike R said:

    @Generic said:
    @Mike R said:
    @Generic said:

    Hi, Mike.

    I'm new to C++. Started to program för Symbian Series 60 in C++ this spring.
    Just an small School- project for developing an Calendar application.

    I have got the feeling that variable i shuld be set. There is nothing that states that it is 0.
    And i wonder why do you declare the variable before the if-statement?


    >>Crosses Fingers<< Please be joking. Please be joking. Please be joking.


    Me like Mike. Mike is funny.
    But you did not answer my question. This makes Generic sad.
    Please make me happy by answering my question.


    Okay, let me spell it out for you in explicit terms.

    Because the code was a joke. Why do you think the post was swimming in sarcasm? Did you bother to read the discussion after the post? Apparently not. It was never meant to be taken seriously, or even work. Generally if I plan on doing a for loop like that, I initialize the variable in the initialization segment of the for loop. i.e. for(int i = 0; i < n; i+=11) etc...

    Some terms you may be unfamiliar with:

    joke
    n.

    1. Something said or done to evoke laughter or amusement, especially an amusing story with a punch line.
    2. A mischievous trick; a prank.
    3. An amusing or ludicrous incident or situation.
    4. Informal.
      1. Something not to be taken seriously; a triviality: The accident was no joke.
      2. An object of amusement or laughter; a laughingstock: His loud tie was the joke of the office.

    See definition 1.

    sar·casm
    n.
    1. A cutting, often ironic remark intended to wound.
    2. A form of wit that is marked by the use of sarcastic language and is intended to make its victim the butt of contempt or ridicule.
    3. The use of sarcasm. See Synonyms at wit<FONT size=-1>1</FONT>.

    See definition 2.

    I would like to inform you Mike that I have been practicing my skill, or lack of skill in sarcasm. But due to my logic way of thinking I find it hard.

    Do you have any tricks that I could use?


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.