2014-03-24 72 views
1

我已經在網上搜索,沒有任何幫助。這是導致錯誤的代碼:編輯包含更多代碼。在Visual Studio 2013中給我R6010調試錯誤。調試錯誤R6010

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("[email protected]#[email protected]#&[email protected]#*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); 
+2

你得到什麼錯誤? –

+1

調試錯誤R6010 - abort()被稱爲 – user3376098

+0

Uhm,所以這是,我從錯誤信息開始R6 ...在Visual Studio中發生?你並沒有給我們很多背景。什麼是'rData'? IN'rData'是什麼?是否有可能想出一個可以由其他人運行的小而完整的代碼示例? –

回答

1

這是從我的代碼中可以推斷出的一種猜測。當您致電

rData.find("[email protected]#[email protected]#&[email protected]#*LlL"); 

...但它沒有找到該子字符串,那麼變量的開始可以設置爲一個隨機值。 (在我的測試程序中,它是一個巨大的整數。)

然後稍後嘗試使用start中存儲的(undefined)值來再次解析字符串。

我懷疑這就是你所看到的......一個「超出界限」的錯誤。另見this question