First of all I'd sugest that you clean up and tidy up your code, because I'm having big troubble trying to read it.(try tabs, etc)
Second, Can you explain the problem a little further? I've just started C++ as well but I can't really get what you're trying to do. What does m represent for instance?
Also, do not use system("pause").Here's a more elegant way of keeping your console open:
Also, you're asking questions for C++ although you're using C libraries. I suggest you go through the tutorials on this site, or get a good book for begginers. I've bought myself "C++ without fear" and I'm quite happy about it.