Archived

This topic is now archived and is closed to further replies.

Motwner

converting to a constant

Recommended Posts

I have been working on a simple program that reads a number from a text file and then implements that number into an array bracket... example: File>>chOut; scanf(chOut,"%d",&tri); TRI*TRIptr[tri]; The problem is that ''tri'' must be a constant, right? Please show me how to convert tri to a const. Thank ya... -Later

Share this post


Link to post
Share on other sites
eh sorry about the above ...anyways....

scanf(chOut,"%d",&tri); im gathering is actually "sscanf"

TRIptr[tri]; should be fine for referencing
but the whole line "TRI*TRIptr[tri];"

doent make much sence TRI = TRIptr[tri] would.
what are you trying to do here ?

Share this post


Link to post
Share on other sites
sorry for the lack of info.

TRI is acually a class. You see I''m working on a very simple glut engine. TRI stands for triangles. I''m reading in how many triangles the engine must make. Every time I run the program, an error tells me that ''tri'' must be constant. Is there any way possible I can convert the integer ''tri'' to a constant?

Share this post


Link to post
Share on other sites
sorry for the lack of info.

TRI is acually a class. You see I''m working on a very simple glut engine. TRI stands for triangles. I''m reading in how many triangles the engine must make. Every time I run the program, an error tells me that ''tri'' must be constant. Is there any way possible I can convert the integer ''tri'' to a constant?

Share this post


Link to post
Share on other sites
going by that then you should have something like

  
TRI *triangles;

File>>chOut;
scanf(chOut,"%d",&tri);

triangle = new TRI[tri];


should work ..

though I still dunno what "TRI*TRIptr[tri];" is suppose to do ?

Share this post


Link to post
Share on other sites