Array initialization... (parse error before '{' token)
Hi there, I was hoping someone might be able to help with this...
to make it very simple, basically I have a header file that contains (amoungst other things ), this:
and another header file containing this:
Code:
double **dmatrix(long nrl, long nrh, long ncl, long nch);
and a function in another file (that #includes both those headers) that contains:
Code:
c = dmatrix( 1, 11, 1, 11 );
c[1] = { 0.999024,-0.097646,-0.144791,0.000000,0.000000,-0.071434,-0.078089,0.000000,0.000000,-0.012807,-0.011995 };
c[2] = { 0.016061,0.170886,-0.058516,0.000000,0.000000,0.307973,-1.998076,0.000000,0.000000,1.217080,-0.045655 };
c[3] = { 0.000000,0.000000,0.000000,0.054546,0.000000,0.000000,0.000000,1.673483,0.000000,0.000000,0.000000 };
c[4] = { 0.000000,0.000000,0.000000,0.000000,0.054546,0.000000,0.000000,0.000000,1.673483,0.000000,0.000000 };
c[5] = { -0.007430,0.166496,-0.178301,0.000000,0.000000,-0.720239,0.732894,0.000000,0.000000,1.443381,-0.184702 };
c[6] = { -0.008108,0.225381,0.815775,0.000000,0.000000,0.322442,2.143341,0.000000,0.000000,-0.655258,-0.326022 };
c[7] = { 0.000000,0.000000,0.000000,0.955720,0.000000,0.000000,0.000000,-1.374817,0.000000,0.000000,0.000000 };
c[8] = { 0.000000,0.000000,0.000000,0.000000,0.955720,0.000000,0.000000,0.000000,-1.374817,0.000000,0.000000 };
c[9] = { 0.004465,0.068339,-0.490358,0.000000,0.000000,1.445710,-0.201925,0.000000,0.000000,-0.695100,-0.242895 };
c[10] = { 0.000499,0.264514,-0.062677,0.000000,0.000000,-0.094937,-0.037686,0.000000,0.000000,-0.080919,-1.370790 };
c[11] = { 0.001650,0.474061,-0.068550,0.000000,0.000000,-0.681962,-0.420221,0.000000,0.000000,-0.784010,1.503431 };
when I try to compile it, I get this:
Code:
basis.c: In function `initializeBasis':
basis.c:64: error: parse error before '{' token
basis.c:65: error: parse error before '{' token
basis.c:66: error: parse error before '{' token
...
basis.c:74: error: parse error before '{' token
I know I must be doing something wrong... perhaps with pointers...
oh and one other thing - it works fine when I do
Code:
...
c[11][1] = 0.001650;
c[11][2] = 0.474061;
...
(the entire file is generated by a perl script i wrote that parses the output of a fortran program called GAMESS, which does quantum chemical calculations - just in case people were wondering why i had so many hardcoded values).
can anyone suggest anything?
oh! almost forgot! - the function dmatrix() does the memory allocation for the array... (and that all works fine btw - so no problems there that could be causing it)
cheers :)
James