This may seem a very basic thing to do, but so far I can't achieve it.
I need to convert a char array (effectively a char *) to a string to be able to read a folder using a DirectoryInfo structure.
Effectively I have a static main directory and a variable sub-directory that a concatenated together. However the DirectoryInfo structure needs a string.
I have tried simple assignment 'str = chr', a loop for all the chars in the char *, neither of these have worked.
I have searched this and other forums for solutions to this problem, but they all seem to give compilation errors.
Oh, I'm using Microsoft Visual C++ 2010 express.
Can anyone help?
int main( void )
std::string emptyString = "";
// fill in your array here
// assign the values in the array to a string
for( int index = 0; index < arrayOfStuff.size(); ++index ) // size in this case is 100
emptyString[index] = arrayOfStuff[index];
// emptyString.c_str()[index] = arrayOfStuff[index];
this isn't really complete and probably has errors but i don't have a compiler to check. You might not need to use .c_str() becuase im pretty sure you can access the individual elements of a string simply by using an index. if this isnt the answer you were looking for, could you post some code or restate your question so more people can add their ideas as well.
Actually vlad is correct it is C++/CLI.
If this board supported attachments I could show what some of the errors look like. I will have to cut/paste some of the compilation errors these various options throw up.
Watch this space as it may take a little time to get them all together.