char                   *pBuff="12345678";
int                    i=strlen(pBuff);
static unsigned char   szOutBuff[1024*2];memset( szOutBuff, 0, sizeof(szOutBuff) ); int iRet = DecodeWaveData((unsigned char* )pBuff, strlen(pBuff), szOutBuff, sizeof(szOutBuff) ); 
当执行DecodeWaveData,系统提示"0x000633e7处有未经处理的异常:0xC0000005:写入位置0x0006cde0时发生访问冲突",调试跟踪了一下,当执行到函数的"( *(szInBuff + ii) ) &= ucTemp;"语句时出现该提示,本人刚学VC,为什么会出现这样的提示,求各位帮帮忙,多谢!附函数:
int DecodeWaveData(  unsigned char* szInBuff, unsigned long ulInLen, unsigned char* szOutBuff, unsigned long ulOutMaxLen ) 
{
unsigned long iBlockCount = 0 ; 
 
// 编码后的数据包的大小必须是8的倍数 
    // 因为一个数据块的大小是8字节 
if ( (0 != ( ulInLen % 8 )) || (0 == ulInLen) )  
{   
return -1; 


// 计算编码后数据包数据块的数量
iBlockCount = ulInLen / 8; 

// 计算输出缓冲区是否足够存放解码后的波形数据
if ( ulOutMaxLen < (iBlockCount * 7) )  
{  
return -1; 


for ( UINT32 i = 0; i < iBlockCount; i++ ) 

// decode one block 
for( INT32 ii = 0; ii < 7; ii++ ) 

// check Bit[7] is 1  
if ( 0 == ( ( *(szInBuff + ii) ) & 0x80 ) )  
{     
return -1; 


unsigned char ucTemp = ( ( *(szInBuff + 7) ) << ( 7 - ii ) ); 
ucTemp |= 0x7f; 

( *(szInBuff + ii) ) &= ucTemp; 


// copy the decode 7 bytes to output buffer 
memcpy( szOutBuff + i * 7, szInBuff, 7 ); 

// decode next block 
szInBuff += 8; 


// total bytes count of the decoded data 
return (iBlockCount * 7); 
}

解决方案 »

  1.   

    补充一下(调用如下):
    char *pBuff="厚勍亖€亐€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€?";
    int i=strlen(pBuff);static unsigned char szOutBuff[1024*2];
    memset( szOutBuff, 0, sizeof(szOutBuff) );  int iRet = DecodeWaveData((unsigned char* )pBuff, strlen(pBuff), szOutBuff, sizeof(szOutBuff) );  
      

  2.   

    我把程序简化了一下:
    char *pBuff="ZMW|厚勍亖€亐€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€?";unsigned char ucTemp = ( ( *(pBuff + 7) ) << ( 7 - 0 ) ); 
    ucTemp |= 0x7f; 

    ( *(pBuff + 0) ) &= ucTemp;执行到最后一句,出现“0x000633e7处有未经处理的异常:0xC0000005:写入位置0x0006cde0时发生访问冲突”错误提示,求解
      

  3.   

    你的pBuff中的数据为啥都是乱码啊?上次给你解答问题你给分了吗?
      

  4.   

    不客气。可是你没有回答我你的pBuff为什么初始化了好多乱码?