#### Archived

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

# converting to a constant

This topic is 6182 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
File>>chOut;
scanf(chOut,"%d",&tri);
TRI*TRIptr[tri];

##### 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 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 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 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 ?

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633696
• Total Posts
3013393
×