Oh man this is tuff!

I don't know were my error is. It's producing a "debug assertion failed" error.

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
76
77
78
        int length;
	int height;
	int L;
	int H;
	char r;
	string s;
	int c;
	int hop;
	int q;
	int d;
	double per;
	double w;
	double u;
	double p;

s = "*";

	cout << "What is the transmition range?" << endl;
	cin  >> hop;

	if (hop == 1)
	{
		H = height;

		do							
		{
			L = 0;

			do
			{
				q = H + 1;
				if (grid[H][L] == s && grid[q][L] == s)
				{
					
					cout << "Point (" << H << "," << L 
                                                << ") and (" << q << "," << L 
						<< ") can communicate." << endl;
				}

				q = H - 1;
				if (grid[H][L] == s && grid[q][L] == s)
				{
				
					cout << "Point (" << H << "," << L 
                                                << ") and (" << q << "," << L 
						<< ") can communicate." << endl;
				}

				q = L + 1;
				if (grid[H][L] == s && grid[H][q] == s)
				{
					
					cout << "Point (" << H << "," << L 
                                                << ") and (" << H << "," << q 
						<< ") can communicate." << endl;
				}

				q = L - 1;
				if (grid[H][L] == s && grid[H][q] == s)
				{
					
					cout << "Point (" << H << "," << L 
                                                << ") and (" << H << "," << q 
						<< ") can communicate." << endl;
				}
				L = L + 1;
			}
			while (L <= length);

			H = H - 1;
			cout << endl;
		}
		while(H > -1);

	}	

	return 0;
}


I think you're stepping out of bounds of your array:

1
2
3
(line 23)        H = height;
(line 31)        q = H + 1;
(line 32)        if (grid[H][L] == s && grid[q][L] == s)


in order for this code to work, 'grid' would need to be 2 rows taller than 'height', which doesn't make sense.

I didn't look too closely but you're probably making off-by-one mistakes like this all over the place. Remember that if an array is 5 elements large, you can only index with 0-4. You cannot index by 5. IE:

1
2
3
4
int foo[5];

foo[4] = 0;  // this is okay
foo[5] = 0;  // this is BAD 
Topic archived. No new replies allowed.