1) Use code tags please... http://cboard.cprogramming.com/c-programming/25765-posting-code-read-first.html

2) You should usually post compilable code in case people want to test it.

3) Read up...