Sin
2013-07-29 21:20:30
How would I do this? I know it's automatic in Java, but not in Pascal :(
2013-07-29 21:20:30
2013-07-29 21:31:42
From: Sin
How would I do this? I know it's automatic in Java, but not in Pascal :(
var
c : Array of Char;
s : string;
i : integer;
begin
c := ['h', 'e', 'l', 'l', 'o'];
s := '';
writeln(length(c));
for i := 0 to 4 do
begin
setlength(s, i + 1); //you really dont need this, it just adds the array length of 's' to the first element
s := s + c[i];
writeln(s);
end;
end.5
5h
5he
5hel
5hell
5hello
2013-08-01 18:28:52
2013-08-06 16:01:09
function CharArrToStr ( CharArr : array of char) :string;
var i,h : integer;
begin
Result := '';
h := high(CharArr);
for i:= 0 to h do
Result := Result + Chararr[i];
end;
function StrToCharArr ( str : string) : array of char;
var i,h : integer;
begin
h := high(str);
setlength(Result,h);
for i :=0 to h-1 do
Result[i] := str[i+1];
end;