Funny programming pictures, jokes & quotes

Discussion about everything. New games, 3d math, development tips...

Postby Mel » Fri Feb 04, 2011 11:39 pm

Great that i <3 u...
http://santiagong.daportfolio.com/
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
User avatar
Mel
Competition winner
 
Posts: 1783
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Postby ent1ty » Sat Feb 05, 2011 11:27 am

The funny part was supposed to be the mushrooms.... nevermind.
I guess i should have said that he is 14.
Height2Normal - convert height maps to normal maps

Code with brain, not heart.
- entity, a proud member of the Heartless Coders society
ent1ty
 
Posts: 925
Joined: Sun Nov 08, 2009 11:09 am

Postby kazymjir » Tue Feb 08, 2011 3:12 am

Mushrooms are very good :D
Unfortunately, it's not season for shrooms.


Image

This one is good :D
kazymjir
 
Posts: 669
Joined: Sat Feb 20, 2010 4:05 pm
Location: Poland

Postby Brainsaw » Tue Feb 08, 2011 6:56 am

Hello World? Need vacation ;)
User avatar
Brainsaw
 
Posts: 1038
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Postby kazymjir » Tue Feb 08, 2011 7:13 am

Brainsaw, are you sure? :D
kazymjir
 
Posts: 669
Joined: Sat Feb 20, 2010 4:05 pm
Location: Poland

Postby pippy3 » Tue Feb 08, 2011 9:26 am

Code: Select all
a:
   goto a




I think it will get into an infinite loop.
pippy3
 
Posts: 155
Joined: Tue Dec 15, 2009 7:32 am

Postby Brainsaw » Tue Feb 08, 2011 11:46 am

kazymjir wrote:Brainsaw, are you sure? :D


Just a wild guess ;). It does, however, almost look as good as the "hello world" of Brainfuck ;)
User avatar
Brainsaw
 
Posts: 1038
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Postby kazymjir » Tue Feb 08, 2011 11:49 am

This picture is very trickery.
All people is starting to analysis those hexadecimal ascii values, but...
look at printf function.
Is there something missing? :)
kazymjir
 
Posts: 669
Joined: Sat Feb 20, 2010 4:05 pm
Location: Poland

Postby hybrid » Tue Feb 08, 2011 12:13 pm

why would you need a separate format string when you already built one? Should work without any problems.
hybrid
Admin
 
Posts: 13943
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Postby kazymjir » Tue Feb 08, 2011 12:56 pm

Ok, I will give you solution.
This code will output... an error.
Why? Because printf() is in stdio.h, which is not included in this code :)

Solutions of most problems are very easy, but human perception always looking for complex solutions, not seeing simple patterns.
kazymjir
 
Posts: 669
Joined: Sat Feb 20, 2010 4:05 pm
Location: Poland

Postby hybrid » Tue Feb 08, 2011 4:10 pm

No, that's an incomplete answer. The thing is that the output of this function was searched. It's also called _tmain, which will probably also not link without a proper main(). But you could still define the output of this function in case it's called (which would also require that it's properly linked before).
hybrid
Admin
 
Posts: 13943
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Postby Bate » Tue Feb 08, 2011 7:11 pm

Put aside all the sophistry and it actually says "Hello World" ;)

Code: Select all
#include <stdio.h>

int main()
{
  char* p=new char[12];*p=0x48;++p;*p=0x65;++p;*p=0x6c;
  ++p;*p=0x6c;++p;*p=0x6f;++p;*p=0x20;++p;*p=0x57;++p;
  *p=0x6f;++p;*p=0x72;++p;*p=0x6c;++p;*p=0x64;++p;
  *p=0x0;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;

  printf(p);
  delete p;

  return 0;
}
Never take advice from someone who likes to give advice, so take my advice and don't take it.
User avatar
Bate
 
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Postby kazymjir » Wed Feb 09, 2011 2:36 am

hybrid wrote:It's also called _tmain, which will probably also not link without a proper main().

_tmain is used in VC++. _t* functions is calling ANSI functions if _UNICODE isn't defined. If _UNICODE is defined, it's calling UNICODE version of that function.
So everything is ok, proper main will be called (main if ANSI, wmain if UNICODE).
But, there don't even must be main() function. Why?
Because, compiler is working always first. If compiler found error in code, it will not run linker.

So, output will be an error that printf() function is not found.
Linker will be not called, because of error found by compiler in code :)
Last edited by kazymjir on Wed Feb 09, 2011 9:31 am, edited 1 time in total.
kazymjir
 
Posts: 669
Joined: Sat Feb 20, 2010 4:05 pm
Location: Poland

Postby Brainsaw » Wed Feb 09, 2011 7:18 am

Here is my optimized version:

Code: Select all
  #include <stdio.h>

int main() {
  char *p=new char[13];
  *p++=0x48;*p++=0x65;*p++=0x6c;*p++=0x6c;*p++=0x6f;
   *p++=0x20;*p++=0x57;*p++=0x6f;*p++=0x72;*p++=0x6c;*p++=0x64;*p++=0x0A;*p=0;
  --p;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;printf(p);return 0;
}
User avatar
Brainsaw
 
Posts: 1038
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Postby kazymjir » Wed Feb 09, 2011 9:10 am

Let's do more optimization!

Code: Select all
int main() {
   char *p=new char[13];
   *p++=0x48;*p++=0x65;*p++=0x6c;*p++=0x6c;*p++=0x6f;
   *p++=0x20;*p++=0x57;*p++=0x6f;*p++=0x72;*p++=0x6c;*p++=0x64;*p++=0x0A;*p=0;
   --p;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;
   __asm__("\
      movl $4, %%eax\n\
      movl $0, %%ebx\n\
      push %0\n\
      pop %%ecx\n\
      movl $13,%%edx\n\
      int $0x80" : :"g"(p)); return 0;
}

kazymjir
 
Posts: 669
Joined: Sat Feb 20, 2010 4:05 pm
Location: Poland

PreviousNext

Return to Off-topic

Who is online

Users browsing this forum: No registered users and 1 guest