-1
I do not understand why this problem is happening, I have already done it in other programs and never had problem, below this function q is giving error, if necessary put all the code.
double Perimetro(Poligono P){
Poligono A, B;
int i = 0;
double *D; //armazena a distancia entre dois pontos
double numvert, soma = 0;
numvert = NumeroDeVertices(P);
D = (double*)malloc(sizeof((double)*numvert));
A = P;
B = P->prox;
for (i = 0; i < numvert; i++){
D[i] = Distancia(A, B);
A->prox = B;
B = B->prox;
soma = soma + D[i];
}
return soma;
}
I believe here: D = (double*)malloc(sizeof((double)numvert); should be: D = (double) malloc(sizeof(double) * numvert);
– anonimo
Why are you declaring the number of vertices as a
double
? Does it make sense to have 3.75 vertices? And why do you create the distance vector, when your problem is clear that it is not necessary to store this information? And what you hoped to get the size of(double)*numvert
? Or you wanted to get the size ofdouble
then multiply bynumvert
?– Jefferson Quesado