How would I do this? I know it's automatic in Java, but not in Pascal![]()
How would I do this? I know it's automatic in Java, but not in Pascal![]()
Simba Code: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.
Code:5 5h 5he 5hel 5hell 5hello
Last edited by Awkwardsaw; 07-30-2013 at 01:35 AM.
<TViYH> i had a dream about you again awkwardsaw
Malachi 2:3
For what do you need a TCharArray? Since you can already do YourString[index]
Working on: Tithe Farmer
Simba Code: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;
There are currently 1 users browsing this thread. (0 members and 1 guests)