Noone is going to debug your program for you. It's about time you learn some debugging techniques.
You can easily debug your own program by simply adding some printf statements, while flusing the output stream after each one. If furthermore, you can make it (buzzword alert) "interactive" with the addition of a getchar call after each.
You could always step through it on paper...
You could learn how to use something like GDB...
You could...
Well, you get the idea.
Quzah.