It can be done simply with 3 strings.
This sounds like a homework problem though so I'll go light on the details.
Declare 3 strings: strNum1, strNum2 and strSum.
Read the #'s to be added straight into strNum1 and strNum2. Each character holds one digit of each number with the least significant digit (ones) at the end. Find which of these 2 strings is the longest. Let's suppose it's strNum2.
Assign strSum = "0" + strNum2. The extra 0 at the beginning gives space for a final carry.
Iterate through strNum1 (use a for loop) from the end to the beginning. You want to add the digits the same way as doing it by hand on paper (working from the least sig. digit to the most sig. digit).
I suggest using several integer variables within the for loop. If we have:
int digit1, digit2, digitSum, carry = 0;
You can extract the integer value from each character with int = char - '0';
Here's an example for finding digit x:
1 2 3 4 5
|
digit1 = strNum1[x] - '0';
digit2 = strNum2[x] - '0';
digitSum = digit1 + digit2 + carry;// value of carry from last iteration
carry = digitSum/10;// value of carry for the next iteration
strSum[x] = digitSum%10 + '0';
|
Hopefully you can get it from there. I may get bashed for giving even that much away!
EDIT: This could be done with just 2 strings. See if you can figure how that would work.