I'd get rid of fflush(stdin), and rely on you to post up whatever problems you have with your program, for the rest.