Hi it's me again.
I know i don't stop posting a lot of stupid thing, but for me it's my only way to progress on my work, i hope you will understand.
Here is my doubt

,
I want to load some data from a ext file, i'm using lesson10 from nehe who already loads data, but i would like to load some extra data.
For example:
----------structure---------------
TEXTURES: (nº of textures)
(It follows the textures to load)
etc..
----------structure---------------
The code from nehe's is this:
//************** START *********************//
void readstr(FILE *f,char *string)
{
do
{
fgets(string, 255, f);
} while ((string[0] == '/') || (string[0] == '\n'));
return;
}
void SetupWorld()
{
float x, y, z, u, v;
int numtriangles;
FILE *filein;
char oneline[255];
filein = fopen("data/world.txt", "rt"); // File To Load World Data From
readstr(filein,oneline);
sscanf(oneline, "NUMPOLLIES: %d\n", &numtriangles);
sector1.triangle = new TRIANGLE[numtriangles];
sector1.numtriangles = numtriangles;
for (int loop = 0; loop < numtriangles; loop++)
{
for (int vert = 0; vert < 3; vert++)
{
readstr(filein,oneline);
sscanf(oneline, "%f %f %f %f %f", &x, &y, &z, &u, &v);
sector1.triangle[loop].vertex[vert].x = x;
sector1.triangle[loop].vertex[vert].y = y;
sector1.triangle[loop].vertex[vert].z = z;
sector1.triangle[loop].vertex[vert].u = u;
sector1.triangle[loop].vertex[vert].v = v;
}
}
fclose(filein);
return;
}
//***************** end *****************//
I though adding this lines to extract extra data:
sscanf(oneline, "TEXTURES: %d\n", &numtextures);
adding this compiles fine under vc++7, but when i execute the program i gives me an error abou allocation error or something like this.
but for the rest i don't know how to do it.
i though using fread from stdio.h and stdlib.h
someone could explain me how it works.
Thanks Again.
Thank you for reading this post, but if you can answer it better.
[edited by - eduardor2k on October 31, 2003 6:42:09 PM]
Thank you for reading this post, but if you can answer it better. :)