var
  stackbuf:pointer;
st1:string;
msgbuf:array[0..255] of byte;
integer(stackbuf):=strtoint(st1);//swr?051222
 fillchar(msgbuf,256,0);
 move(stackbuf^,msgbuf[0],length(st1));
为什么不能move 呢?老报错呢?报错为:
project prepaidserver.exe raised exception class EAccessViolation with message 'Access violation at address 00404886 in module'prepaidserver.exe.'Read of address 00001B69'.Process stopped. use step or run to continue.
为什么不能这样move呢?应该这样把stackbuf中的数据放到msgbuf中呢?

解决方案 »

  1.   

    move(st1[1], msgbuf[0], min(length(st1), sizeof(msgbuf)));
      

  2.   

    我要通过指针把st中数据放到字节数组msgbuf中.我主要问的是project prepaidserver.exe raised exception class EAccessViolation with message 'Access violation at address 00404886 in module'prepaidserver.exe.'Read of address 00001B69'.Process stopped. use step or run to continue.
    这句报错是什么错误?指针用的不对吗?为什么move后会报这样的错呢?还是因为没给stackbuf分配空间啊?
      

  3.   

    内存访问违规阿,就是你没有整对,integer(stackbuf):=strtoint(st1);//swr?051222 <<这句错了strtoint的本意是取字符串所表达的整数,这不是将符号地址强制转换成整数应该
    stackbuf := pointer(st1);不过,尽量避免这样处理,有些情况会让你感到困惑的
      

  4.   

    alphax(弯弯曲曲,和外父老借谷):
    可你写的这样赋值就不可以将stackbuf中的数据move到另一数组中了,因为没有给stackbuf分配内存,而是简单的将stackbuf指向st1而已所以不能move.
    谢谢你!