I have this function
verticeobj* loadverticeObj(char *fname,verticeobj *vo){
FILE *fp;
int read;
float x, y, z;
char ch;
fp=fopen(fname,"r");
if (!fp)
{
printf("can't open file %s\n", fname);
exit(1);
}
while(!(feof(fp)))
{
read=fscanf(fp,"%c",&ch);
if(read==1&&ch=='v')
{
read=fscanf(fp,"%f %f %f",&x,&y,&z);
vo =inserevertice(vo,x,y,z);
}
else
{
if(ch=='f')
{
read=fscanf(fp,"%d %d %d %d",&x,&y,&z,&ch);
}
}
}
fclose(fp);
return vo;
}
It receives the linked list of type verticeobj and returns the filled list. Within the function, when the condition is satisfied, an insert function is called by passing the list again to insert the data in the list. :
verticeobj* inserevertice(verticeobj *lv, float x, float y, float z){
verticeobj* novo = (verticeobj*)malloc(sizeof(verticeobj));
novo->x = x;
novo->y = y;
novo->z = z;
novo->prox = lv;
lv = novo;
return lv;
}
The issue is that in main when I call a function to print the list, it prints the desired elements by two more rows of junk that I'm not sure what it is. Inside the insert function I put a printf to test and it prints all elements correctly. Thanks in advance.