Ok, guys, please don't be mean to me, i'm just a girl trying my hand at this coding thing, and being terribly confused by it.
I have this exercise to creat an abstract data type and in one part of it i need to take some values from a file and create a line using them. On the file I have first the number of points in the line then the pair coordinates of each point. The structs i'm using are this:
typedef struct ponto{
double x;
double y;
} ponto;
typedef struct linha{
double numVertices;
ponto verticesLin[ ];
}linha;
and the function i need to use is this:
void criaLinha (linha *, double , ponto *);
So i wrote this code to make the transition of the data from the file to the buff and then to the struct linha by using that function:
BuffToLine(ponto buff[], numMax, linha *l){
double i;
ponto Aux;
for(i=0, i<numMax , i++){
Aux.x = buff[i].x;
Aux.y = buff[i].y;
criaLinha(*l, i, *Aux);
}
}
void criaLinha (linha *l, double numVertices, ponto *vertices){
*l.verticesLin[numVertices].x = Aux.x;
*l.verticesLin[numVertices].y = Aux.y;
}
The problem is, i don't know how to pass the values from the file to the buffer, and i'm not sure the code i wrote will work, because i can't test is without the buffer. So... could someone help me understand how to creat this buffer and if there is a better way of creating the lines with the 'criaLinha' function?