problem with program exiting after function is called

I am trying to have the user input 2 binary numbers and then adding and multiplying them. The problem that I am having is after I call the first function from the class it exits the program. Any help would be greatly appreciated.

binNum header file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef BINNUM_H
#define BINNUM_H

using namespace std;

class binNum
{
	private:
		char num [5], num2 [5];
	int i, carry, result;

	public:
	binNum();    //Default constructor
	void numbers();
	int addition(int);
	~binNum();


};



#endif 


binNum .cpp file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "binNum.h"		//obtain prototype definitions
#include <iostream>

using namespace std;

binNum::binNum()
{
	i = 0;
	carry = 0;
	result = 0;
	
}

void binNum::numbers()
{
	cout << "Enter a 4 bit binary number entering only 0's and 1's: ";
	for ( i=0; i < 5; i++)
    {
        cin>> num[i];
		
    }
	cout << "Enter another 4 bit binary number entering only 0's and 1's: ";
	 for (i = 0; i < 5; i++)
    {
        cin>> num2[i];
		
		
    }
}

int binNum::addition(int i) 
{

    for(i = 0; i < 32; ++i) {
        int a = (num[4] >> i) & 1;
        int b = (num2[4] >> i) & 1;
        result |= ((a ^ b) ^ carry) << i;
        carry = (a & b) | (b & carry) | (carry & a);
    }

    return result;
}


binNum::~binNum()       // Destructor function definition
{  cout << "press enter to exit"; 
}


main:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "binNum.h"
#include "misc_ops.h"

#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main()
{
	int i = 0;
	binNum num;
	num.numbers();
	num.addition(i);


	  	//keeps the output window open
	cout << "Press enter to continue \n"; 
	cin.ignore();
	char ch = getchar();

  return 0;
}
Try sticking a cin.sync(); before that ignore() on line 19 of main.
thanks works now
Topic archived. No new replies allowed.