/* Put all coefficients to zero */
for (A = 0; A < 4; A++)
{
for (B = 0; B < 4; B++)
{
for (qq = 0; qq < 7; qq++)
{
for (ii = 0; ii < 3; ii++)
{
for (ji = 0; ji < 3; ji++)
{
for (ki = 0; ki < 3; ki++)
{
coefg[A][B][ii][ji][ki][qq] = 0.0;
}
}
}
}
}
}
Name:
Anonymous2007-08-30 13:42 ID:El7RTl5t
I'm amazed at how hardly can you faggots fail. Being C fags and Gentoo ricers all day for this? You don't even know C! You fucking faggots!
In C, i[j][k] can be two different things, depending on how it's defined:
1. If you define i like int **i = malloc(X * sizeof(int *)), or int *i[X], you get a vector of pointers to i, which you're supposed to fill with dynamically-allocated memory. The type of i is int **, and it's not an "array" as far as C's concerned, just a double pointer. When you do i[j][k], C does *(*(i + j) + k). (This is the way Java does "arrays", BTW, which aren't true matrices because rows can have different lengths.)
2. If you define i like int i[X][Y] (where x and y are constants), you get an int array [Y]. This is the true C array. The compiler actually remembers Y, and allocates contiguous memory. Then when you do i[j][k], it actually does *(i + j * Y + k).
So in the case OP's array is an array, malloc will naturally work perfectly, and it's the recommended way to clear it.