请看一下有关拼音的这段代码

sghff110 2010-07-31 09:25:33
function gb2py(hanzi:pchar):pchar;
var
Sfile:Tmemorystream;
pos,temp,ipos,len:integer;
py:array[0..20] of char;
begin
pos:=($fe-$a1)*(ord(hanzi[0])-$b0)+ord(hanzi[1])-$a1;
sfile:=Tmemorystream.create;
sfile.loadfromfile('C:\Program Files\Common Files\Kingsoft\Extract\Sound\gb2py.idx');
sfile.Seek($1608+pos*4,soFromBeginning);
sfile.Read(ipos,4);
sfile.Read(temp,4);
len:=temp-ipos;
sfile.Seek(ipos+1,soFromBeginning);
sfile.Read(py,len);
py[len-1]:=#0;
sfile.Free;
result:=py;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
a:pchar;
b:string;
begin
a:=nil;
strpcopy(a,'你好');

b:=strpas(gb2py(a));

edit1.Text :=b

end;
点按钮时出现调试器异常通知:'Access violation at address 004081B5 in module'project1.exe.
...全文
154 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
SuperTitan007 2010-07-31
  • 打赏
  • 举报
回复
getmem(a,10);
try
strpcopy(a,'你好');
b:=strpas(gb2py(a));
edit1.Text :=b;
finally
freemem(a);
end;

16,747

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧