Writing to a file

Alright, i imported verticies, faces, and normals from a .ase file, and now i want to spit them out into my own (.dan) file… but, when its writing the normals to the file, it stops early… for no reason… it just stops writing… like, in the middle of a line… I have a for() loop to get thru all the normals (in a class)… and then when it gets to like the last 1… it displays only the x,y coords, no z… but if i stop it sooner, it just writes part of the next line… should be “misslemodel (missle)”. It only writes “misslemod”… but the part where it writes that line, is all in one fprintf() line…
Any ideas? Can windows only write so much, or so many chars to a .txt file? (.dan)??
Thanks in advance,
Dan Sherman

post some code. w/out seeing your code, no one can really help you.

jebus

Sorry, at home right now, code at school… it’ll be up tomorrow… Check back for me?

fprintf(s, "#ifndef vect1
typedef float vect1;
#endif

#ifndef vect3
typedef vect1 vect3[3];
#endif

#ifndef triangle
typedef vect1 triangle[3];
#endif

");
fprintf(s, "#ifndef %smodel
typedef struct
{
", mn);
fprintf(s, " vect3 verticies[%i] = {
", p->numVertex);
for (int a=0; a<(p->numVertex-1); a++){
fprintf(s, "{%f,%f,%f}, ", p->verts[a][0], p->verts[a][1], p->verts[a][2]);
if (a%2 == 0){
fprintf(s, "
");
}
}
fprintf(s, "{%f,%f,%f}};
", p->verts[p->numVertex-1][0], p->verts[p->numVertex-1][1], p->verts[p->numVertex-1][2]);

fprintf(s, "	triangle faces[%i] = {
", p-&gt;numFaces);
for (a=0; a&lt;(p-&gt;numFaces-1); a++){
	fprintf(s, "{%i,%i,%i}, ", p-&gt;faces[a].vertIndex[0], p-&gt;faces[a].vertIndex[1], p-&gt;faces[a].vertIndex[2]);
	if (a%2 == 0){
		fprintf(s, "
");
	}
}
fprintf(s, "{%i,%i,%i}};

", p->faces[p->numFaces-1].vertIndex[0], p->faces[p->numFaces-1].vertIndex[1], p->faces[p->numFaces-1].vertIndex[2]);

fprintf(s, "	vect3 facenormal[%i] = {
", p-&gt;numFaces);
for (a=0; a&lt;(p-&gt;numFaces-14); a++){
	fprintf(s, "{%f,%f,%f}, ", p-&gt;faces[a].normal[0][0], p-&gt;faces[a].normal[0][1], p-&gt;faces[a].normal[0][2]);
	if (a%2 == 0){
		fprintf(s, "
");
	}
}

the output from this section looks like this (importing a cube from .ase)
OK, WTF, i run my program on a huge .ase file, and the above happens… i run it on a cube… and it exports NOTHING, absolutly NOTHING…

wierd, after bugging around with it… my order of opps is
Read in;
Export to file;
display model;
If i take out the Displaying… it runs fine, and exports everything…
but if i leave in the displaying… it stops short on the exporting… even though the whole export function is called before the display is ever even mentioned…

are you flushing your buffer and closing the file before you display? do you need the file open for some reason after you’ve written it?

jebus

Aha, never closed the file… that prolly has something to do with it…
Lol, just leaving school now… ill do it tomorrow… thanks a ton man!