rt!

解决方案 »

  1.   

    当然可以,但最好不要对CString的Buff干这种事.
      

  2.   


    代码如下:  int AdapterNum=0;
      char AdapterName[8192]; // string that contains a list of the network adapters
      char *temp,*temp1;
      int i;
      ULONG AdapterLength;
      char AdapterList[Max_Num_Adapter][1024];
      AdapterLength=4096;   PacketGetAdapterNames(AdapterName,&AdapterLength);
       temp=AdapterName;
       temp1=AdapterName;
    while ((*temp!='\0')||(*(temp-1)!='\0'))
    {
    if (*temp=='\0') 
    {
    memcpy(AdapterList[i],temp1,(temp-temp1)*2);
    temp1=temp+1;
    i++;
    }

    temp++;
    }
    AdapterNum=i;Debug时显示消息提示框:unhandled exception in ***.exe(MSVCRTD.DLL):0xC0000005:Access Violation.
      

  3.   

    改为 memcpy(&AdapterList[i],temp1,(temp-temp1)*2);注意memcpy是通过地址来拷贝的!
      

  4.   

    memcpy(AdapterList + i,temp1,(temp-temp1)*2);<==>
    memcpy(&AdapterList[i],temp1,(temp-temp1)*2);
      

  5.   

    根据if (*temp=='\0') 这个条件,你在复制的是一个空字符串,自己再查查是不是逻辑上有问题。还有 while ((*temp!='\0')||(*(temp-1)!='\0')) 的条件是不是有多此一举的地方。
      

  6.   

    还是不行错误照旧。楼上说的情况不会存在的,因为这段代码是我原封不动从winpcap的例程中考过来的,他的运行是没有问题的,只不过他是用的SDK。