The reason why you need to remove return 0; is because when you use a return statement in your main function, it will end the program. In your case, you called a return statement before the pause command, resulting in the application closing before you could read the output.