0

Working with large int numbers. Broken up as char for each digit, total of 3 arrays, n1, n2, and sum. I have everything completed, the math works fine, the arrays work fine, the shuffling to the right side of the array works fine. I just have two issues, that both are in the print department:

1. I know that I can use a count variable to right justify these numbers like the professor wants, i just cannot for the life of me figure out how to implement it or how to do it a different way.

2. On the 3rd set and the 6th set of numbers, they stop printing for some reason. Again, I know its something I am doing wrong in the printing method, just not sure what.

my code:

```
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
ifstream dataIn;
ofstream dataOut;
void printarry(int arg[]);
int zeroArray(int arg[]);
int getNum(int arg[]);
void spacer();
int adder(int arg1[], int arg2[], int arg3[]);
int adder(int arg1[], int arg2[], int arg3[]){
for(int x = 26; arg1[x-1] != 0 && arg2[x-1] != 0; x--){
int c;
c = arg1[x-1]+arg2[x-1]+arg3[x-1];
arg3[x-1] = c%10;
arg3[x-2] = c/10;
}
}
//basic array printer using an array and a lenth as params
void printarray (int arg[]) {
int x = 0;
for (int n=0; arg[n] == 0; n++){
x++;
}
for(int n = x; n < 26; n++){
cout << arg[n] << " ";
}
cout << "\n";
}
int zeroArray (int arg[]) {
for (int n=0; n<26; n++){
arg[n] = 0;
}
}
int getNum(int arg[]){
char x;
int i=0;
dataIn.get(x);
while(x != '\n'){
arg[i] = x-'0';
i++;
dataIn.get(x);
//arg[i] = x-'0';
}
}
int shuffle(int arg[]){
int count = 0;
int back = 26;
int digits = 0;
//get total digits
for(int i = 26; arg[i-1] == 0; i--){
count=count+1;
digits = back - count;
}
for(int i = digits; i > 0; i--){
arg[back-1] = arg[i-1];
arg[i-1] = 0;
back--;
}
}
void spacer(){
cout << "-------------------------------------" << endl;
}
int main(int argc, char *argv[])
{
int n1[26], n2[26], sum[26];
dataIn.open("BigNumbersV2.txt");
for(int x = 6; x > 0; x--){
zeroArray(n1);
zeroArray(n2);
zeroArray(sum);
getNum(n1);
getNum(n2);
shuffle(n1);
shuffle(n2);
printarray(n1);
printarray(n2);
adder(n1,n2,sum);
spacer();
printarray(sum);
cout << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
```