Modifying string length?_(re)

Thu, 1 May 1997 12:14:42 +0100 (BST)


On Thu, 1 May 1997 13:40:14 +0200 (MET DST) Peter Gerwinski 
 wrote:
>According to The African Chief:
>> 
>> However, what  happens when you want to add a string to
>> the end of it? Check this example, and look at the ouput
>> under Borland;
>> 
>> program Fred;
>> var
>> s,s1:string[40];
>> begin
>>  s  := 'Fred Smith'+#0;
>>  s1 := s + 'is okay'; 
>>  writeln ( s1 ); 
>> {prints "Fred Smith is okay" - where did the space before "okay" 
>> come from? I didn't want or put it there - viz; problem with trailing "#0"}
>> end.
>
>It's no space; it's a #0, as you requested.

Yes.

>The above is an *explicit* trailing #0.  It is part of the string and
>must not vanish when adding another string.

True.

>The *implicit* trailing #0 to be appended for CString compatibility
>*will* vanish; however the program above will still produce the same
>result.

That is okay then. I just thought that the point needed to be 
made, that there could be a problem with a trailing #0. If the
compiler makes the ones that it adds to vanish away, the
problem disappears.

Best regards, The Chief 
Dr Abimbola A. Olowofoyeku (The African Chief, and the Great Elephant)
Author of:  Chief's Installer Pro v3.12 for Win16 and Win32.
Homepage:  http://ourworld.compuserve.com/homepages/African_Chief/
E-mail: laa12@cc.keele.ac.uk



The African Chief (laa12@cc.keele.ac.uk)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es