PDA

View Full Version : c++ question (OT)



robert
11-26-2000, 04:44 PM
I know this is not really a Opengl related question, but can someone pls help me http://www.opengl.org/discussion_boards/ubb/smile.gif!!!

I am playing around with bezier curves in opengl and I want to read my information in from a txt file into an array of 3xNxN (eg array[3][N][N2]). The values for N and N2 are contained in the txt file itself.

The problem is that I want the array to be global, and to do that I have to declare it before I have read from my txt file. So if i try to declare this array before i have the values the complier will disagree (of course!)

This is what I would like to do:

1 Read in txt file()

2 declare an array to the values in the txt file

NOT:

1 Declare an array to say [3][100][100]
2 Read in array.

I know this sounds confusing, and I should know the answer to this but If anyone could help Itd b appreciated!!
thanks

11-26-2000, 05:36 PM
this little program should show you how to do it

#include <stdio.h>

char *** array;

int main()
{
//attempting to create a new char [5][4][3]; stick your own values
array=new char ** [5];
for(int i=0; i<5; i++)
{
array[i]=new char * [4];
for(int j=0; j<4; j++)
array[i][j]=new char[3];
}

array[0][0][0]='c';
printf("%c", array[0][0][0]);
return 0;
}

robert
11-26-2000, 05:55 PM
That worked great!!

Thanks for your help