Originally Posted by
King Mir
....while 100 is surely a high enough....
My code is just for my own testing/learning.
Looks like you need to copy the directory names into an array of strings, instead of keeping a pointer. I recommend using an array of std::string instead of char *.
Thanks, changing that worked. However, could you/someone possibly explain why the above code doesn't work as intended but the following does;
Code:
#include <iostream>
using namespace std;
int main()
{
char *aChar[15] = { "0" };
char *cString[] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "end" };
for(int i=0; cString[i]<"end" ; i++)
{
aChar[i] = cString[i];
}
for(int i=0; cString[i]<"end"; i++)
{
cout<<aChar[i]<<endl; //displays array as intended
}
cin.get();
}