When you set the 'release' option, the command line to build your code is very different. Visual Studio sets the optimizations settings and other thinks. You can see that command line, in the project configurations: -> C/C++ compiler ( or something like this ) -> command line ( option )
see the picture: