Thank you to everyone who tried to help with my bug. I have since found out that the bug only occurs if I produce an executable file using the QuickC package. If I use the normal cl compiler then it works fine. So there definately seems to be a bug in QuickC. Matthew Fletcher, University of Bath, England