while (*p != '\0' || *q != '\0')
This makes no sense. p and q are pointers to int arrays that you created. When did you put the value '\0' in them? Never.
You seem to have taken the idea that a C-string is an array of char with a '\0' on the end, and from this mistakenly inferred that any array of ints will also magically have a '\0' on the end. They won't.
Line 21 in your stringtoInt appears to be a cut and paste error. You're working on string one, twice, and nevre working on string 2.
I've been trying to debug this for hours but i can't seem to figure out how
Debugging is easy. It's asking yourself questions. here are the first questions to ask yourself?
1) Are the strings being read in correctly?
2) Are the strings being reversed correctly?
3) Are the reveresed strings being turned into int arrays correctly?
Here is how to answer the first two questions:
1)
1 2 3 4 5 6 7
cout << "Enter the first string" << endl;
cin >> str1;
cout << "Check first string: " << str1 << endl;
cout << "Enter the second string" << endl;
cin >> str2;
cout << "Check second string: " << str2 << endl;
You were right. Somehow there's some issue when i reverse my string, but i'm still unable to print out the correct arithmetic calculation. Sorry, i'm still new to pointer. I can't really think of any other alternative way to do the calculation if the array are being declared as pointer.
Your function void reverseString(string s1) is being passed a copy of the string. It will work on that copy, and when the function finishes, the copy is thrown away. So even when you get the string reversing correctly, you will then be throwing away the reversed sting. You could return that copy, to make use of it, but you're not returning it; just discarding it.
You are using "pass by value". Now that you know the term for it, you can look up "pass by value" and "pass by reference" and understand what you're doing.
Array are for advanced users. As a beginner, you should be using std::vector.
One obvious problem with your reverseString function is that you're passing s1 by value, not reference. s1 goes out of scope when reverseString exits and the results are lost.