Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Funny C code  (Read 32798 times)

0 Members and 1 Guest are viewing this topic.

50m3R3%31

    Topic Starter


    Greenhorn

    Funny C code
    « on: April 21, 2008, 12:05:01 AM »
    This is some really funny code (although you have to open it at the command prompt). Call the file stop.

    #include <stdio.h>

    _______________________________________ _______________________________________ ________
    int main()
    {
    printf("Cannot stop: Bad mood error.")
    return(0)
    }

    _______________________________________ _______________________________________ ________

    Har har!

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Funny C code
    « Reply #1 on: April 21, 2008, 11:56:30 AM »
    Not to be critical and notwithstanding your claim of not being a noob, your snippet will not compile.

    Code: [Select]
    #include <stdio.h>

    int main()
    {
    printf("Cannot stop: Bad mood error.");
    return(0);
    }

    As I read in another post, attention to detail is critical in programming (no matter how you spell it!)

     8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    Aegis



      Expert

      Thanked: 67
      • Yes
      • Yes
      • Brian's Mess Of A Web Page
    • Experience: Experienced
    • OS: Windows 10
    Re: Funny C code
    « Reply #2 on: May 01, 2008, 07:13:04 PM »
    Is that a loop which reprints "Cannot stop: bad mood error."?



    "For you, a thousand times over." - "The Kite Runner"

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Funny C code
    « Reply #3 on: May 08, 2008, 10:34:43 AM »
    looks like that was the intention- but as it stands it will just show it once and go back to the prompt.


    heres one that simulates the prompt.... I made it in VC++ 6- other compilers will likely require the removal of the stdafx line I believe.
    well here it is.

    #include "stdafx.h"
    #include <string.h>
    #include <iostream.h>
    int main(int argc, char* argv[])
    {
       char cmdline[128];
       char crlf[7]="\0xD\0xA";
       int currmsg=-1;
       do
       {
       currmsg++;
       cout << endl;
       printf("C:\\>",crlf);
       gets(cmdline);
       cout << endl;
       if (currmsg==0)
          printf("An Error occured processing a token in command line '%s'.%s A Possible reason may be you smell.",cmdline,crlf);
       else if (currmsg==1)
          printf("Disk error while processing command '%s'. Ensure you have applied sufficient deodorant to prevent your hard disk from being offended.",cmdline);
       else if (currmsg==2)
          printf("I was just about to execute your command, '%s', but changed my mind at the last second.",cmdline);
       else if (currmsg==3)
          printf("hey, stop telling me what to do. I'm not going to perform a '%s' just for you.",cmdline);
       else if (currmsg==4)
       {
          printf("crap, it worked this time.");
           for(int i=0;i<15;i++)
             {
             printf(".");
          }
          printf("whew, something bad happened when I tried.");
       }   
       else if (currmsg==5)
          {
             printf("for gods sake, I thought you'd give up already!");
             currmsg=-1;
          }
          printf(crlf);
       } while (stricmp("quit",cmdline)!=0);
       printf("%s%sdarn, you said the secret word. oh well.",cmdline);
       return 0;
    }






    I was trying to dereference Null Pointers before it was cool.

    priyanka raut



      Newbie

      • Experience: Beginner
      • OS: Unknown
      Re: Funny C code
      « Reply #4 on: February 16, 2012, 05:56:43 PM »
      pls snd me c code for "everyone is having interest in rearrangements. find all the rearrangements possible with 0-9 digits without repetition of digit in number and count them. the number  should contain distinct digit. the number should not start from 0."