注册 登录
编程论坛 Delphi论坛

编译通过运行不了,求解

continue24 发布于 2013-10-15 22:40, 2427 次点击
用 delphi 编写一个输出除去输入字符串中所有空格的串的程序(我编写的程序编译通过了,但是不知道为什么运行就会出错,无法运行)
program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var a:string;
    b:string;
    p1,p2:^char;
    i:integer;
    t:integer=1;
begin
  { TODO -oUser -cConsole Main : Insert code here }
  readln(a);
  i:=length(a);
  p1:=@a;
  p2:=@b;
  repeat
  if p1^<>' ' then
   begin
    p2^:=p1^;
    Inc(p2);
   end;
   Inc(p1);
  until t=i;
  writeln(b);
  readln;
end.
2 回复
#2
haiou3272013-10-15 23:33
代码算法没什么逻辑关系
#3
true10232013-11-15 10:37
不能直接操作string类型,换char数组
1