Originally Posted by Gene Poole
In debug mode, the compiler allocates extra memory on each end of the stack and fills it with a specific value (0xCD I believe). After the function returns, the debug routines check that all those values at the ends of the stack are still what it set at the beginning. If not, it triggers the message you are getting.
In short, you are smashing your stack somehow and the compiler is telling you about it. Fix your code to make it go away.
Thanks for the help but i can't see where it's going wrong. I'll have to stick with the exit(0) for now as i need to get this finished fast. So long as it works now i can always have a look at a later date