General Knowledge Basic General Knowledge Subjective
Mar 19, 2013

Write a program to initialize large number of strings?

Detailed Explanation

- Strings are used as a constant and it helps in creation of the procedure and for the initialization process.

- Find the strings and assign it to the variable string. Then create a special string type that will help in initialization process.

- A custom procedure is required to initialize the string and use it to show some output and it is as follows:

const strlen = 250; { our "big" string }
cstlen = 12; { our constant strings }
type string = packed array [1..strlen] of char;
cstring = packed array [1..cstlen] of char;
var s: string;
procedure inistr(var s: string; c: cstring);
begin
for i := 1 to strlen do s[i] := ' '; { clear result }
for i := 1 to cstlen do s[i] := c[i] { place string }
end;
...
inistr(s, 'hello, world');

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback