He says to me that I cannot use matriz[5][5] because that doesn't exist.
BTW, the allocation:
Code:
float **criacao_tdd (int pola, int *c) //tdd[c][c+1] c= numero de pontos
{
float **tdd;
int n;
char op;
do{
system("cls");
printf("\t\t\tCriacao da Tabela Das Diferencas Divididas \n\nQuantos pontos se utilizara na tabela? \n(Numero de pontos máximos: %d)", pola);
scanf("%d", c);
if(*c>1 && *c <= pola)
do{
printf("\nDeseja Alterar o valor introduzido? S/N");
op = toupper(getch());
}while(op != 'S' && op != 'N');
}while(*c<=1 || *c>pola || op == 'S');
tdd = (float **) calloc (*c, sizeof(float *));
for ( n = 0; n < *c; n++ )
{
tdd[n] = (float*) calloc (*c+1, sizeof(float));
if (tdd[n] == NULL)
break;
}
if(tdd == NULL || tdd[n] == NULL)
{
do{
printf("\nErro: não há memória \nDeseja introduzir um novo valor? (S/N) \n\n");
op = toupper(getch());
}while(op != 'S' && op != 'N');
if (op == 'N')
exit(1);
else
tdd=criacao_tdd(pola, c);
}
return (tdd);
}
EDIT: When I call the function that allocates this, I do this: tdd = criacao_tdd(pola, c);
One function that use it:
Code:
int px (int c, float tdd[][c+1], float x)
{
int coluna = 1, linha = 0, op_erro, aux = 0;
float px = 0, aux_calculo;
char op;
do{
system("cls");
printf("Deseja Calcular o Erro? ");
op = toupper(getch());
if (op == 'S')
op_erro = 1;
if (op == 'N')
op_erro = 0;
}while(op_erro != 1 && op_erro != 0);
for(coluna = 1; coluna < c+1-op_erro; coluna++)
{
aux_calculo = tdd[0][coluna];
for(linha = 0; linha < aux; linha++)
aux_calculo = aux_calculo*(x-tdd[linha][0]);
aux++;
px = px+aux_calculo;
}
printf("\n\nX = %f ",px);
return op_erro;
}