Please do not post the same post twice on different threads. It will not help you get help any faster, and just serves to clutter up the forum.
I don't know any C, so I really can't help you there. However, this seems more like something you need to learn to do instead of asking for help, as it seems like you are asking for someone to do it for you.
What code have already developed for this?