I had no problem with your program with VC++ 6.0. It generated a stack overflow, however, with VC++ 2005. I checked the stack commit and stack reserve sizes in the project properties and found that both were set to 0. I set them to 1000 and fixed the problem. In 2005 you will find this at Project/(project name) Properties/Configuration Properties/Linker/System.