• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++ question

Kur

Senior member
I just upgraded to VS2008 and it seems I keep getting this very annoying problem, whenever I write a program it works, however at the end when it outputs the answer I can barely see the output but the window instantly closes.

Any ideas?

Edit. my code and output info.

// ******************************************************
//
// SumProduct.cpp
//
// This program prompts the user for two integers then
// outputs their sum and product.
//
// ******************************************************

#include <iostream>
using namespace std;

int main()
{
//
// Variable declarations
//
int num1, num2;
int sum, product;


//
// Read in two integers
//
cout << "Enter an integer: ";
cin >> num1;

cout << "Enter another integer: ";


// --------------------------------
// ----- ENTER YOUR CODE HERE -----
// --------------------------------
cin >> num2;
sum = num1 + num2;
product = num1 * num2;

cout << "The sum is: " << sum << endl;
cout << "The product is: " << product;

// --------------------------------
// --------- END USER CODE --------
// --------------------------------


cout << "The end!!!\n";

return 0;
}

'Chapter1.1.exe': Loaded 'C:\Users\Nrg\Documents\Visual Studio 2008\Projects\Chapter1.1\Debug\Chapter1.1.exe', Symbols loaded.
'Chapter1.1.exe': Loaded 'C:\Windows\System32\ntdll.dll'
'Chapter1.1.exe': Loaded 'C:\Windows\System32\kernel32.dll'
'Chapter1.1.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcp90d.dll', Symbols loaded.
'Chapter1.1.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcr90d.dll', Symbols loaded.
The program '[1596] Chapter1.1.exe: Native' has exited with code 0 (0x0).
 
You either need to run the program outside the IDe or follow the advice of Cogman to place a read request at the end of the program. This allows you to observe the output before the program closes.
 
Back
Top