I'm getting a string subscript error. Just can't seem to figure out what it is? can someone please help me find the error. Would highly appreciate it and the error does happen at the runtime.
void addnumber_formula(string one,string two, int result[],int resultsize)
{
//Declare sum to store the sum of indexes
int sum=0;
int lastnum=0;
int carry=0;
int row=0;
int counter;
//find the length of each string.
int length1, length2;
int max;
length1=one.length();
length2=two.length();
//Determine which one of these is a max
if (length1>length2)
max=length1;
else
max=length2;
//make a for loop to get each letter of a string
for (counter=one.length();counter>0;counter--)
{
sum=(one[counter]-'0')+(two[counter]-'0')+carry;
//Find the last number of sum
lastnum=sum%10;
//find first number of sum
carry=sum/10;
//store last number in the result
result[row]=lastnum;
row++;
//if max is equal to one then make sure to enter carry in the array
if (counter==1)
{
result[row]=carry;
}
}
}
void print_addition(int result[],int size)
{
for (size;size>0;size--)
cout<<result[size];
}
int _tmain(int argc, _TCHAR* argv[])
{
//Cal he function to get the twenty digit number
string one,two;
display(one, two);
int results[4];
//Call addnumberformula
addnumber_formula(one, two, results,4);