LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 11-19-2009, 03:53 PM   #1
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
C programming puzzle


Coolin' down from all the flame wars about making good code, its time to test how somone is at decoing bad code:
can you tell what this does without running it:
Code:
#include <conio.h>
#define DZF92(c, x) (((c)==0)?0:(((x%2)==0)?(c-1):(c-2)))
void pstx(char *s){
int i = 0;
while(putch(DZF92(s[i], (++i)))){
if(DZF92(s[i], i) == ','){gotoxy(wherex() + 1, wherey());}
}
}
int main(){
char boopalot[] = {' ', 74, 102, 110, 109, 113, 45, 121, 112, 116, 109, 102, 34, 0};
pstx(boopalot);
return 0;
}
 
Old 11-19-2009, 04:18 PM   #2
mjones490
Member
 
Registered: Sep 2005
Distribution: LFS
Posts: 60

Rep: Reputation: 22
Looks to me like it prints "Hello, world!" on the screen.
 
Old 11-19-2009, 06:58 PM   #3
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by mjones490 View Post
Looks to me like it prints "Hello, world!" on the screen.
LOL you must have ran it.
 
Old 11-19-2009, 07:15 PM   #4
sarum1990
Member
 
Registered: Dec 2008
Distribution: Gentoo, Debian
Posts: 31

Rep: Reputation: 21
That's pretty cool, I actually went through it line by line. Awhile ago I stumbled across a single file that was, a bash program, a Makefile, and C source code, all with very tricky comment notation so that if you made the file executable, you could like run it 3 times and compile and run a C program. That was probably the craziest obfuscation I've seen in code. Can't find it now, but it was really interesting.
 
Old 11-20-2009, 08:05 AM   #5
mjones490
Member
 
Registered: Sep 2005
Distribution: LFS
Posts: 60

Rep: Reputation: 22
Quote:
Originally Posted by smeezekitty View Post
LOL you must have ran it.
I ran it on my brain.

No, it's just that I've seen enough obfuscated "Hello, World!" programs to recognize the ASCII codes for the letters, and with the little "subtract one from every other character", that accounts for the simple mutations in the codes.
 
Old 11-20-2009, 08:13 AM   #6
mjones490
Member
 
Registered: Sep 2005
Distribution: LFS
Posts: 60

Rep: Reputation: 22
My favorite obfuscated program is the one with three lines of mostly parentheses, that when you run it it prints out a naked woman showing her poonanners to the whole world.
 
Old 11-23-2009, 01:23 AM   #7
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by mjones490 View Post
My favorite obfuscated program is the one with three lines of mostly parentheses, that when you run it it prints out a naked woman showing her poonanners to the whole world.
obfuscation is fun!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A puzzle Gins Linux - General 10 02-24-2007 07:23 AM
Puzzle: How can employer test C++ programming ability? ArthurHuang Programming 13 05-22-2006 02:58 AM
GTK puzzle Chuck23 Fedora 9 08-24-2004 03:04 AM
Simple C Puzzle sansk Programming 20 05-22-2004 04:09 PM
Binary Puzzle aioss Linux - Software 0 02-07-2004 01:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 07:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration