Archived

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

jwblair

Array of words - Trouble!

Recommended Posts

jwblair    122
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

Share this post


Link to post
Share on other sites
sjelkjd    171
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

Share this post


Link to post
Share on other sites
jwblair    122
What I did was this...

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

And it works for me!

Thanks!

Thanks!

John William Blair

Share this post


Link to post
Share on other sites