Please get a good debugging tool (MSVS, GDB) and go through your code line by line. This method will help you to resolve some big mistakes you have done here. Then ask the people what you have missed if something still doesn't work.
Please help yourself first, it is pleasure to help those who deserve the help.