CStrings_(re)
Mon, 28 Apr 1997 18:03:35 +0200
Peter Gerwinski wrote:
> I encountered some problems with Procedures accepting `CString'
> parameters. When passing a string constant to such a parameter, GPC
> does *not* automatically add a "chr ( 0 )" terminator.
>
> Should it do? And if so, in which cases? We always can explicitly write
> "foo ( 'bar'#0 );" instead of just "foo ( 'bar' );", so I tend to let
> things like they are ...
I think it should automatically add a #0 terminator. After all, a "CString"
without terminator is somewhat undefined.
In which cases? I think always when a string constant is given where a
"CString" value is expected, whether for a parameter, or a variable
initializer. E.g. the following should work as expected:
var numbers:array[1..3] of cstring value (1:'one';2:'two';3:'three');
or in BP syntax:
const numbers:array[1..3] of pchar=('one','two','three');
Many of my programs rely on this.
--
Frank Heckenbach, Erlangen, Germany
heckenb[No_Spam! Remove this to reply.]@mi.uni-erlangen.de
Turbo Pascal: http://www.mi.uni-erlangen.de/~heckenb/programs.htm
Internet links: http://www.mi.uni-erlangen.de/~heckenb/links.htm
Frank Heckenbach (heckenb@mi.uni-erlangen.de)
HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada -
Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es