ERROR : invalid types ‘double[int]’ for array subscript

Receiving this error "invalid types ‘double[int]’ for array subscript" on this snippet of code on line 17 and 27:

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

// Normalization for the p(H|I)

	double cee, pHI[3];

	cee = 1/ (ph[0] + ph[1]+ph[2]);

	for (x=0; x<3 ; x++){

		pHI[x] = ph[x]*cee;
		cout << pHI[x] << endl;
	}

// Normalization for p(D|HI)*p(H|I) ---> {p(D|I)} kay for constant 

	double kay;
	kay = 1 / (ans[0]*pHI[0] + ans[1]*pHI[1] + ans[2]*pHI[2]);

// Final calculation 

 cout << "------------------- FINAL ---------------------" << endl;

	double final[3];
	
	for(x=0; x<3 ; x++) {
	
		final[x] = ans[x]*pHI[x]/kay;
		cout << final [x] << endl;
	}


cant seem to figure out what is going on Im pretty sure im not stepping outside of the array boundaries.

Thanks in advance for any help :)
Put spaces around '*' on these lines
Compiler thinks of them as of dereference operator here.
Last edited on
spaces are free.

¿how is `ans' defined?
 
double ans
MiiNiPaa the spaces make no difference
ans is a single double, not an array. So you cannot apply subscript operator to it.
Last edited on
right on, i thought i had changed that into an array earlier but i must have forgotten to save it!!

Thanks a million!!

Cheers
Topic archived. No new replies allowed.