Comparing two arrays

im programming to be able to enter two digits, and these two digits need to be read from the back in... I'm supposed to use pointers, but i worked on this thing for 12 hours straight with no progress on the pointers. >.< this stuff makes me wanna kill myself, but i did some research and found (sort of) a way around it through establishments of a new array but it is still flawed when running. WIthout just telling me an answer, could an experienced helpful individual assist me in the right direction as far as how i could use a pointer to make this algorithim work, or perhaps just give me some pointers on how to make the backwards loop run correctly?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Comparing()//comparing integers
{
	char temp1 [80] = " "; // character array identifying its size
	char temp2[80] = " ";
	char temp3[80] = " ";
	int length1 = 0, length2 = 0, i = 0, j = 0, count = 0;
	cout << "Enter integer 1 : ";
	cin >> temp1;
	cout << "Enter integer 2 : ";
	cin >> temp2;

	while (temp1[length1] != '\0'){ // loop stating the temp1 variable length
		length1++;
	}

	while (temp2[length2] != '\0'){ // while loop identifying temp2
		length2++;
	}

	
	cout << endl;
	if (length2 > length1)
	
	{
		cout << "number of comparison : " << length1 << endl;
		j = length1 - 1;
		for (i = length2 - 1; i >= length1 - 1; i--, j--)
		{ // check that will go through array as soon as identifying the number and decrementing
			temp3[i] = temp1[j];
		}

		for (i = length2 - 1; i >= (length2 - length1); i--)
		{
			if (temp3[i] == temp2[i])
			{
				cout << temp3[i] << "<---->" << temp2[i] << "Bingo!" << endl;
				count++;
			}
			else
				cout << temp3[i] << "<---->" << temp2[i] << endl;
		}
	}
	else if (length1 > length2){
		cout << "number of comparison : " << length2 << endl; // check in array. length 1 is now greater than length 2
		j = length2 - 1;
		for (i = length1 - 1; i >= length2 - 1; i--, j--)
		{
			temp3[i] = temp2[j];
		}

		for (i = length1 - 1; i >= (length1 - length2); i--)
		{
			if (temp3[i] == temp1[i]){
				cout << temp3[i] << "<---->" << temp1[i] << "Bingo!" << endl;
				count++;
			}
			else
				cout << temp3[i] << "<---->" << temp1[i] << endl;
		}
	}
	else{
		cout << "number of comparison : " << length1 << endl; // comparision of values for the length 1 in array
		for (i = length1 -1; i >= 0; i--){
			if (temp1[i] == temp2[i]){
				cout << temp1[i] << "<---->" << temp2[i] << "Bingo!"<< endl;
				count++;
			}
			else
				cout << temp1[i] << "<---->" << temp2[i] <<endl;
		}
	}

	cout << "number of same digit : " << count<< endl;

}
Im not sure I understood the directions...Can you clarify?
So you take two array of characters that the user input lines 8 and 10, then how could you compare the last digits of each one?? i tried to mess with using pointers (*rear1 = strlen(temp1)-1; rear2 = strlen(temp2)-1) and then tried to make a for loop that runs through both of them for comparison but i couldnt make it work my program would go bezerk. so i attempted with this algorithm and no pointers, but it only works properly if the lengths of the two are equal. If temp1 is larger than temp2 or vis versa, it will only compare the last two digits. >.<
Topic archived. No new replies allowed.