C / C++ / C#

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
photo of David Bolton

David's C / C++ / C# Blog

By David Bolton, About.com Guide to C / C++ / C#

C Programming Puzzle

Monday December 1, 2008
What does this piece of C code do? It's from a book and provided as an example of how not to layout code because it looks horrible.

main(int v,char**c){
if(--v){
  main(v,c) ; c[v][0]^=0x80;
  for(c[0][0]=0;c[++c[0][0]]!=0;)
     if(c[c[0][0]][0]>0)
       puts(c[c[0][0]]) ;
   puts("-- ") ;
  main(v,c) ;}}

Answer on Wednesday!

Comments

December 2, 2008 at 11:49 am
(1) wuxie says:

It’s a Hanoi tower.

December 3, 2008 at 2:18 am
(2) sudh says:

what parameters need to be passed to this program

December 3, 2008 at 8:21 am
(3) Lavock says:

It’s a application of Hanoi tower, to find all combination of list of argument.

Use c[0][0] is not very clean for system.

December 3, 2008 at 1:34 pm
(4) shara says:

i wanted to make puzzel game with c but i had trouble in making its pieces correct. what should i do?

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss

Community Forum

Explore C / C++ / C#

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

C / C++ / C#

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.