# Working with 2D array in a structure

Hi everyone, fine?

This is my structure header file :

``````#ifndef PRESSION_H_INCLUDED
#define PRESSION_H_INCLUDED

typedef struct PRESSION PRESSION;
struct PRESSION
{
signed int si_Consignes[11];

unsigned int ui_TempIndex; // en °C/10
signed int si_TempPrises[3];

signed int si_ValeursPrises[11][3]; // 0 : TA @ 5°C
// 1 : TA @ 35°C
// 2 : TA @ 75°C

double ud_GainOffset[11][3];        // 0 : Gain @ 5°C  // Pression->si_GainOffset[5][i] correspond a l'offset
// 1 : Gain @ 35°C
// 2 : Gain @ 75°C

double ud_DeriveGainOffset[11][3];  // 0 : Derive @ 5°C  // Pression->si_DeriveGainOffset[5][i] correspond a la dérive de l'offset en température
// 1 : Derive @ 35°C
// 2 : Derive @ 75°C

signed int si_TempAmbiante;

signed int ValeurEnCours;
signed int OffsetEnCours;
double GainEnCours;
signed int ValeurCorrigee;

};

void InitPression(PRESSION *pression, signed int si_ConsigneLow);
void GetValues(PRESSION *pression);
void CalculOffset(PRESSION *pression);
void CalculGain(PRESSION *pression);
void Process(PRESSION *pression);
#endif // PRESSION_H_INCLUDED
``````

And this is the method which doesn’t work :

``````void CalculGain(PRESSION *pression)
{
for(int j = 0; j < 3; j++)
{
for(int i = 0; i < 5; i++)
{
pression->sd_GainOffset[i][j] = (double)(pression->si_ValeursAdcParfaites[i][j]) / (double)(pression->si_ValeursPrises[i][j] + pression->sd_GainOffset[5][j]);
}
for(int i = 6; i < 11; i++)
{
pression->sd_GainOffset[i][j] = (double)(pression->si_ValeursAdcParfaites[i][j]) / (double)(pression->si_ValeursPrises[i][j] + pression->sd_GainOffset[5][j]);
}
}
}
``````

error : suscripted value is neither array nor pointer nor vector.

I read somewhere I had to use double pointer, but don’t know how and if it works…

Thank’s guys!

I don't have my glasses but your array `pression->[color=red][b]s[/b][/color]d_GainOffset` does not seem to exist...

don't you mean `pression->[color=green][b]u[/b][/color]d_GainOffset` ?

You have declared a one dimensional array here:

``````    signed int si_ValeursAdcParfaites[11];
``````

and tried to use it as a two dimensional array here:

``````            pression->sd_GainOffset[i][j] = (double)(pression->si_ValeursAdcParfaites[i][j]) / (double)(pression->si_ValeursPrises[i][j] + pression->sd_GainOffset[5][j]);
``````