3DS file

Really i am unable to solve this one
I made an exact code for load all vertex from any file
but there is some assignment problem
here is the code(i changed something)

int nvert
float **vertex;
void Load3Ds(const char *Filename,float **vert,int x)
Lib3dsFile *testfile;
Lib3dsIo *testio;

printf("Testing 3-Dimention of 3ds 
how to load 3ds file for reading all vertes data

testfile = lib3ds_file_open(Filename);
 x = testfile->meshes[0]->nvertices;

printf("Number of vertices %i

vert = new float*[2];

for(int i=0;i<=x;i++)
vert[i] = new float[x];

fprintf(stdout,"size of block by vert is %i


and when i called

fprintf(stdout,"Test of 3ds file complete vertex scaning
Load3Ds("test.3ds",vertex, nvert);
if(!vertex)fprintf(stdout,"vertex can't initialised
else if(!x)
fprintf(stdout,"count of vertex can't initialised
/*if all false show on console*/

at the point of

Load3Ds(“test.3ds”,vertex, x);
if(!vertex)fprintf(stdout,"vertex can’t initialised
else if(!nvert)
fprintf(stdout,"count of vertex can’t initialised

i found vertex and x are not assigned
in my other OpenGL programs which use Load3ds function
they give up
and message come out

Segmentation fault 3232 ./3dtes

if i use int prototype to define Load3ds
and assign to nvert
nvert works
but vertex not assigned
and vice versa(prototype float assigned vertex but nvert??)
(these things sometimes caught by glibc for look like as a bug with long list of /lib/i915_drm(drm,intel was there exact i don’t know)
when i put value of nvert manually after knowing value of testfile->meshes[0]->nvertices)

the problem is not come when i put
these line at last of Load3ds definition

nvert = x;
vertex = vert;
}//<-Function definition ends

but using these assignment
is not good idea
please anyone can help me on this perticular
cause i tried so much but these problem not solved very well
any Suggestion in defining function please reply
:frowning: i hope anyone who read this can understand my problem :frowning:
please reply to this
in this situation i am really helpless :sorrow:

please give at least link resource if possible
cause i found there no docs of lib3DS just three examples
in the source package

There is a working 3DS loader in the Oolong engine, among other places on the internet. Just grab one of those and save yourself a lot of time. :slight_smile:

Just skimmed this, but you do

vert = new float*[2];
for(int i=0;i<=x;i++)
vert[i] = new float[x];

So you allocate an array of pointers to floats with a size of TWO and then assigned values to that array from 0 to X. So do you expect X to always be 2?

Also, you pass X by value into Load3DS and assign a value to it without reading it. So why pass it in? Do you understand what “pass by value” means? i.e. you pass in a COPY of X and assign to the COPY which is lost when the function returns (the original X is unchanged).

Finally, this isn’t an advanced question. It seems more like a basic need to learn to program question.

thanks you bring out my old memories (as i forget & at definition)
i redefined that function with float prototype(returns the vert) and with & of count of vertex
now i can load a 3DS file
only with vertex{x,y,z} part of file
now i am heading to Material cameras and blablaz.
thanks dude. :smiley:
i hope 3DS loader helps