In this section, we’ll address some of the common issues that new programmers seem to run across with fairly high probability. This is not meant to be a comprehensive list of compilation or execution problems, but rather a pragmatic list of solutions to very basic issues. If you have any suggestions for other issues that might be added to this list, post them in the comments section below. General run-time issues Q: When executing a program from the IDE, the console window blinks and then closes immediately. First, add or ensure the following lines are near the top of your program (Visual Studio users, make sure these appear after #include “pch.h” or #include “stdafx.h”, if those exist): 1 2 #include "iostream" #include "limits" Second, add the following code at the end of your main() function (right before the return statement): 1 2 3 std::cin.clear(); // reset any error flags std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // ignore any characters in the input buffer until we find an enter character std::cin.get(); // get one more char from the user
You've reached the end of your free preview.
Want to read both pages?
- Fall '16
- Computer program, Letter case, Integrated development environment