std::string::npos equivalent for managed code
I have a native code snippet that I am going to write in managed code instead.
The native snippet code look like this:
std::string RClammer = "]";
std::string BigLine = "aaaaaaaa]aaaa";
int pos = 0;
while(std::string::npos != (pos = BigLine.find(RClammer, pos)))
{
BigLine.insert(pos + 1, " ");
pos = pos + 2;
}
My attemt to write that in managed code look like below but the application just "freeze" when I run this code, so I might beleive I am doing something wrong but dont know all logics of what I am doing excactly ?
I think it has to do something with ::npos that I dont get right ?
String^ RClammer = "]";
String^ BigLine = "aaaaaaaa]aaaa";
int pos = 0;
while(BigLine->Length != (pos = BigLine->IndexOf(RClammer, pos)))
{
BigLine.Insert(pos + 1, " ");
pos = pos + 2;
}
Darth Vader
Junior Poster in Training
63 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
Okay, perheps my attempt is not correct. The native code works fine.
What could be a correct way to write this native code for managed. I am not sure of what I will do except for what I have tried.
Darth Vader
Junior Poster in Training
63 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
thank you, your code worked fine. I will check this out.
thanks again !
Darth Vader
Junior Poster in Training
63 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0