I have a struct like this:
struct vertices{
char x[20];
char y[20];
char z[20];
};
and then in main I have an array of the struct vertices like this:
struct vertices vert[64];
plus an array of char in my main function like this:
char exampleArray[200]="v 23.232000 32.33000 2.03900\nv 9.20900 3.29000 1.0002\n";
so what I want to do is to parse this big array containing a hundred or so vertices, and store each value in the corresponding x,y,z char arrays of the struct vertices, which later I'm gonna simply convert by calling on
float x=atof(vert[1].x)
and draw each one.
But the problem is that I can't store , copy, concat characters from the raw array to the x,y,z arrays by any ways, i tried to do it by vert[0].x=exampleArray[0], vert[0].x=exampleArray+i
etc inside different conditions like
if(SpaceCount==1)
{
vert[0].x[0]=exampleArray[i];
i++;
}
but all this doesn't work.
I tried so many variations, couldn't list them all. But the thing I want is to parse the exampleArray which has my vertices in raw format, every 3D vertix has spaces in between them, every vertix starts with a char V followed by a space, the first point is the X then followed by a space and then the Y point and after the Z point there is newline \n character and then again a V for a new vertix.