I have this program. It is an example from a book. I am using Dev-C++ and my program just runs and close and I cannot see results. I have two questions
1 - Is the try/catch block ok, becuase it doesn t seem to work sometimes.
2 - How can I get to make my program pause without using system('pause"). I have use cin.get(); as you can see but it seems to work only on some type of programs.
Anyway I am a C++ beginner so anyhelp would be greatly appreciated
GCard
#include <fstream>
#include <stdexcept>
#include <iostream>
using namespace std;
struct division
{
float dividend;
float divisor;
float answer;
};
int main ()
{
division localdivide;
try
{
cout << "Please enter a number. \n";
cin >> localdivide.dividend;
cout << "Please enter another number.\n";
cin >> localdivide.divisor;
localdivide.answer = localdivide.dividend/localdivide.divisor;
cout << localdivide.dividend << "divided by " ;
cout << localdivide.divisor << " is " << localdivide.answer;
cout << "Press enter to continue";
cin.get();
}// end of the try blcok
catch(...)
{
cout << "an error occurred!";
}
return 0;
}