Array of words - Trouble!
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
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement