A
anelma via .NET 247
Following code works fine, when compiled with VS 6.0, but not anymore when compiled in .NET. What's wrong here, I can't see it by myself?
arrString content will be garbage with .net compilation, but when compiled with 6.0 it contains string from Vector (that's how I want it to work).
std::vector<std::string> Vector;
...
void MyClass:oThis(std::vector<std::string> Vector)
{
const char *arrString[10];
for (int i = 0; i < 10 && i < Vector.size(); i++)
arrString = Vector.c_str();
When I debug these, I see that the problem is with my array of const char*. Const char* items seems to change, when std:string changes. For example,
Vector[0].c_str = "dog"
arrString[0]="dog"
Vector[1].c_str = "cat"
arrString[0]="cat" --> this is the problem, why it happens?
This happens only with .net, with 6.0 remains arrString[0] = "dog"
arrString content will be garbage with .net compilation, but when compiled with 6.0 it contains string from Vector (that's how I want it to work).
std::vector<std::string> Vector;
...
void MyClass:oThis(std::vector<std::string> Vector)
{
const char *arrString[10];
for (int i = 0; i < 10 && i < Vector.size(); i++)
arrString = Vector.c_str();
When I debug these, I see that the problem is with my array of const char*. Const char* items seems to change, when std:string changes. For example,
Vector[0].c_str = "dog"
arrString[0]="dog"
Vector[1].c_str = "cat"
arrString[0]="cat" --> this is the problem, why it happens?
This happens only with .net, with 6.0 remains arrString[0] = "dog"