Integers over 50 digits

I am making a program that will allow the user to add two 50+ digit numbers together using arrays and a class named LargeInt. Upon inputting the number, the program will put that number in an array and output it to a string. I am trying to convert the char that is in the program to a string and things will not translate properly. I am also not sure why my program puts "-" in between every number after the addition. Any suggestions?

LargeInt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
#pragma once
class LargeInt
{
public:
	LargeInt() {};
	void ADDITION();
private:
	int Number1[255], Number2[255] , ADD[255];
	char S1[255], S2[255];
	int L1, L2;
};

  


LargeInt.cpp
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
49
50
51
52
53
54
55
56
57
58
#include "LargeInt.h"
#include <string>
#include <iostream>
#include "stdafx.h"

using namespace std;

void LargeInt::ADDITION()
{
	cin >> S1;
	cin >> S2;

	for (L1 = 0; S1[L1] != '\0'; L1++)
	{
		Number1[L1] + S1[L1] - '0';
	}
	for (L2 = 0; S2[L2] != '\0'; L2++)
	{
		Number2[L2] = S2[L2] - '0';
	}
	int carry = 0;
	int k = 0;
	int i = L1 - 1;
	int j = L2 - 1;

	for (; i >= 0 && j >= 0; i--, j--, k++)
	{
		ADD[k] = (Number1[i] + Number2[j] + carry) % 10;
		carry = (Number1[i] + Number2[j] + carry) / 10;
	}

	if (L1 > L2)
	{
		while (i >= 0) {
			ADD[k++] = (Number1[i] + carry) % 10;
			carry = (Number1[i--] + carry) / 10;
		}
	}
	else if (L1 < L2)
	{
		while (j >= 0) {
			ADD[k++] = (Number2[j--] + carry) / 10;
		}
	}
	else
	{
		if (carry > 0)
			ADD[k++] = carry;
	}
	cout << S1 << endl;
	cout << S2 << endl;
	cout << "Sum of your two large numbers = ";

	for (k--; k >= 0; k--)
	{
		cout << ADD[k];
	}
}


main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include "LargeInt.h""

using namespace std;


int main()
{
	cout << endl;
	cout << "Enter a number to calculate the addtion of two large numbers" << endl;

	LargeInt digit;

	digit.ADDITION();

	system("pause");
    return 0;
}
Line 15 in LargeInt.cpp.
 
Number1[L1] + S1[L1] - '0';

Since you're missing a = this statment effectively does nothing at all.
You meant to put = instead of +.

The compiler would probably not have told you about this if you didn't use -Wall.
Topic archived. No new replies allowed.