store a long integer (20 digits) into a string then convert to an int array

I cannot store the value as an int because it is too large, so it has to be done with a string or char. I then must convert that to int array and add it to another one
example:
77777777777777777777 + 22222222222222222222<enter> = 99999999999999999999
so I have this so far, which is printing out garbage
edit: I cannot use long long for this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  string input1;
string operation;
string input2;
int array1[20];
int array2[20]; 
cin >> input1 >> operation >> input2;

    if (input1.length() > 20)
        cout << "Invalid Operand (too large). " << endl;

or (int i = 0; i <= 20; i++)
    {


        input1[i] = array1[i];
        if (input1[i] = " ")
            input1[i] = 0;
    }
    cout << array1;
Last edited on
Did you try this?
1
2
3
4
5
6
7
8
9
10
string operation;

unsigned long long input1;
unsigned long long input2;
unsigned long long result;

cin >> input1 >> operation >> input2;

result = input1 + input2;
cout << "The result : " << result << endl;
oh I should have stated that long long would not work, or at least I'm not allowed to use it. It has to be read in as a string then converted to a int array.
Topic archived. No new replies allowed.