Home / Software / Computer programming / Funny C code
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: Funny C code  (Read 4647 times)
50m3R3%31
Topic Starter
Greenhorn



Posts: 5


« 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!
IP logged
Sidewinder
Guru



Thanked: 97
Posts: 4,342

Experience: Familiar
OS: Windows 7

« 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)
IP logged

If you don't know where you are going, any road will get you there

                                                                            -Lewis Carroll
Aegis
Expert



Thanked: 67
Posts: 2,698

Experience: Experienced
OS: Windows XP



Brian's Mess Of A Web Page 1
« Reply #2 on: May 01, 2008, 07:13:04 PM »

Is that a loop which reprints "Cannot stop: bad mood error."?

IP logged



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


Thanked: 697
Posts: 15,880

Computer: Specs
Experience: Beginner
OS: Windows 7


Pinkie Pie is best pony

BC-Programming.com 1 1
« 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;
}






IP logged

My Blog

BASeBlock 2.3.0 (NOW WITH MACGUFFINS!)
priyanka raut
Newbie



Posts: 1

Experience: Beginner
OS: Unknown

« 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."
IP logged
Pages: [1] - (Top) Print 
Home / Software / Computer programming / Funny C code « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.118 seconds with 20 queries.