two-dimensional dynamic array, const char* adding
I'm currently writing code on Windows that I later hope to transfer over to the mac.
I initialize a two-dimensional, dynamic array (both dimensions are dynamic), then I read in from a file to the array:
char** managerNames = new char*[20];
for(int x = 0; x < 20; ++x)
{
managerNames[x] = new char[20];
}
//the input reading is not important...a string is read into something such as managerNames[0]
Then I need to make another string that has "Objects\", and then whatever is contained in managerNames[0], and then "\meshList.txt". I have to eventually use this string in the fscanf() function as the filename parameter. After trying a ton of different things to make it work, I can still not come up with any usable code.
Any help on this problem is appreciated
-wyrmmage
Also: I doubt if it makes any difference, but I need to pass the string to a function before it is used in the fscanf() function, and the string will also eventually be passed from that function into a yet another function, where I will have to make another filename that is similiar to the one I am trying to create above; for that reason, it would be nice if you could also show me how to pass the value that is in managerNames[0] into the function, and then assemble the string inside the function, so I can re-use the variable that was passed to the function. If you don't want to put the code in that form, but know something useful, I'd still like to hear it because I can probably figure out how to pass managerNames[0] in the right form on my own.
I initialize a two-dimensional, dynamic array (both dimensions are dynamic), then I read in from a file to the array:
char** managerNames = new char*[20];
for(int x = 0; x < 20; ++x)
{
managerNames[x] = new char[20];
}
//the input reading is not important...a string is read into something such as managerNames[0]
Then I need to make another string that has "Objects\", and then whatever is contained in managerNames[0], and then "\meshList.txt". I have to eventually use this string in the fscanf() function as the filename parameter. After trying a ton of different things to make it work, I can still not come up with any usable code.
Any help on this problem is appreciated

-wyrmmage
Also: I doubt if it makes any difference, but I need to pass the string to a function before it is used in the fscanf() function, and the string will also eventually be passed from that function into a yet another function, where I will have to make another filename that is similiar to the one I am trying to create above; for that reason, it would be nice if you could also show me how to pass the value that is in managerNames[0] into the function, and then assemble the string inside the function, so I can re-use the variable that was passed to the function. If you don't want to put the code in that form, but know something useful, I'd still like to hear it because I can probably figure out how to pass managerNames[0] in the right form on my own.
Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Code:
std::string fileName = std::string("Objects/") + managerNames[0] + "/meshList.txt";
can you use a string as a parameter in the function fscanf(), or is there a way to convert a string back to a char?
*EDIT*
After a bit of looking around, I think that I have found how to turn strings back into char's. Thanks for the help man
-wyrmmage
*EDIT*
After a bit of looking around, I think that I have found how to turn strings back into char's. Thanks for the help man

-wyrmmage
Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Adding static gravity object | game_ding | 4 | 4,230 |
Mar 28, 2008 05:25 PM Last Post: Skorche |
|
| char array versus pointer to string constant question | WhatMeWorry | 7 | 6,641 |
Jan 30, 2007 12:26 PM Last Post: bronxbomber92 |
|
| dynamic array not working properly | wyrmmage | 4 | 3,073 |
Dec 8, 2006 03:22 PM Last Post: wyrmmage |
|
| Killing the char on the end of a char array | wyrmmage | 3 | 2,943 |
Dec 4, 2006 08:55 PM Last Post: wyrmmage |
|
| What... the... heck? Const Char & Chars. | Jones | 6 | 2,969 |
Jun 12, 2006 03:54 PM Last Post: akb825 |
|

