Array of words - Trouble!

Started by
1 comment, last by jwblair 23 years, 1 month ago
I am trying to create a array of words that I can use as texture names and locations as done in Lesson 6 with NeHe. But all that I know how to do is an array of characters. So lets say that I have the following code: char *FileName; FileName = "Data/Crate.bmp"; And Lets say that I have lots of filenames, lets say 10 in all. And lets say that I want to put each filename in array so that it is easy to access later. How would I go about doing that? Can anyone help? Any help would be appreciated! Thanks! John William Blair
Thanks!John William Blair "The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of the darkness. For he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee."
http://members.home.com/chucklez/wtc/index.html
Advertisement
if you know the max number at compile time, use a static array like this:
char file_names[NUM_WORDS][MAX_CHAR_PER_WORD];

then
char temp[MAX...]
for(int i=0;i{
cin>>temp;
strcpy(filenames,temp);
}


but i prefer the STL:

std::vector file_names;
then it can expand dynamically
What I did was this...

char *FileName[] = {"Data/Crate.bmp","Data/Crate.bmp"};

And it works for me!

Thanks!

Thanks!

John William Blair
Thanks!John William Blair "The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of the darkness. For he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee."
http://members.home.com/chucklez/wtc/index.html

This topic is closed to new replies.

Advertisement