I've been working on a little home project to increase my skill as a programmer.
It's a basic inventory simulator, however there's one section of code in the program that I used from a book, and I'm not entirely sure what's going on...
1 2 3 4 5 6
|
string* pszArr = new string[11];
for(int i = 0;i < 10; ++i) //initializes inventory default to be "---"
{
pszArr[i] = "---";
}
|
Now pszArr is the virtual inventory, it is an array, 11 long consisting of string elements. The program is
very basic, so the items (like a sword, helmet etc, typical RPG stuff :) ) are simply string objects, assigned to elements in the array when a command "give" is given.
Basically I'm wondering if there is a way to streamline this snippet of code so that it initializes all elements in the array to "---" without having this iterative loop that I think is quite unwieldy. (Sorry if i'm terrible at explaining my problem, I'm new to all of this troubleshooting stuff )