Question

I have the following code, if i don't put the printf(" "); segment is violated, else it works fine

void dispersion(float ***plancha_ptr, float ***copiaPlancha_ptr) {
    float **plancha = *plancha_ptr;
    float **copiaPlancha = *copiaPlancha_ptr;     

    //Calculo del borde absorbente(superior) y reflectante (inferior)
    for(int i = 0; i <= SIZE_Y+1; i++) {
        plancha[0][i] = 25;
        plancha[SIZE_X+1][i] = plancha[SIZE_X][i];  
    }

    //Calculo de los bordes reflectantes (laterales)
    for(int i = 0; i <= SIZE_X+1; i++){
        plancha[i][0] = plancha[i][1];
        plancha[i][SIZE_Y+1] = plancha[i][SIZE_Y];      
    }
    //Calculo de la dispersion
    for(int j = 1; j < SIZE_X+1; j++)
        for(int k = 1; k < SIZE_Y+1; k++)
            copiaPlancha[j][k] = (plancha[j-1][k-1] + 
                                  plancha[j-1][k] +
                                  plancha[j-1][k+1] + 
                                  plancha[j][k-1] +
                                  plancha[j][k] + 
                                  plancha[j][k+1] +
                                  plancha[j+1][k-1] + 
                                  plancha[j+1][k] +
                                  plancha[j+1][k+1]) / 9;

    //RESTAURAR PTO DE CALOR
    copiaPlancha[X_ORIGIN][Y_ORIGIN] = TEMP;
    //INTERCAMBIO DE PUNTEROS PARA EVITAR COPIA DE MATRIZ   

    float **p;
    **p = ***plancha_ptr;
    *plancha_ptr = *copiaPlancha_ptr;
    //No Tocar, hay que imprimir por pantalla o no funciona
    // printf(" ");
    //***copiaPlancha_ptr = **p;
    return;
}

It doesn't work, but if I un-comment the printf it works fine. I need help.

Thanks!

Was it helpful?

Solution

Try changing these lines

float **p;
**p = ***plancha_ptr;

to

float **p;
p = *plancha_ptr;

You should init p before you can de-reference it as **p.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top