I'm doing a simple addition arithmetic using pointer array but i'm stuck at trying to print out my pointer array.
int main()
{
string str1, str2;
cout << "Enter the first string" << endl;
cin >> str1;
cout << "Enter the second string" << endl;
cin >> str2;
stringtoInt(str1, str2);
}
void stringtoInt(string& s1, string& s2)
{
int size1, size2;
int i = 0;
intPtr intArray;
intPtr intArray2;
intArray = new int[MAX];
intArray2 = new int[MAX];
size1 = s1.size();
size2 = s2.size();
for (int i = 0; i < size1; i++)
{
intArray[i] = s1[i] - '0';
}
for (int i = 0; i < size2; i++)
{
intArray2[i] = s1[i] - '0';
}
}
void addInteger(intPtr intArray, intPtr intArray2)
{
int *p = &intArray[0];
int *q = &intArray2[0];
intPtr total;
total = new int[MAX];
int i = 0;
int sum = 0;
int carried = 0;
while (*p >= 0 || *q >= 0 || carried == 1)
{
total[i] = *p + *q + carried;
if(total[i] > 9)
{
total[i] %= 10;
carried = 1;
}
else
carried = 0;
}
}
However, i do not have the size for my pointer. So how do i print out my pointer array?