Reputation: 39
I've already searched online and none of it helped me. This is the code that's causing the error: Edited to include more code. Gives me the R6010 debug error in Visual Studio 2013.
do
{
rLength = recv(s1, rBuf, 1, 0);
if (rLength > 0)
{
rData += rBuf[0];
if (rBuf[0] == nByte[0])
{
switch (rData[0])
{
case 'C':
uid = rData.substr(1, 3);
statSend = "00" + uid + "ST" + userinfo;
charStat = statSend.c_str();
lLength = send(s1, charStat, strlen(charStat) + 1, 0);
break;
case 'M':
if (rData[4] == 'C' && rData[5] == 'H');
{
size_t start = 6;
size_t end = rData.find("!@#$!@#&!@#*LlL");
size_t start2 = rData.find("*LlL");
size_t end2 = rData.find(";");
cout << rData.substr(start2, end2 - start2) << ":" << rData.substr(start, end - start) << endl;
}
break;
}
rData = "";
}
}
} while (rLength > 0);
Upvotes: 1
Views: 5040
Reputation: 320
This is a guess from what I can infer from your code. When you call
rData.find("!@#$!@#&!@#*LlL");
...but it doesn't find that substring, then the variable start could be set to a random value. (In my test program it was a huge integer.)
Then later you try to USE the (undefined) value stored in start to parse through the string again.
I suspect that's what you're seeing... an "out-of-bounds" error. See also this question.
Upvotes: 1