CStrings/PChars_(re)
Wed, 18 Jun 1997 12:14:36 +0100 (BST)
On Tue, 17 Jun 1997 16:18:14 +0200 (MET DST) Peter Gerwinski
wrote:
>According to The African Chief:
>>
>> Great! Now one last thing about pChars - can you make
>> them type-compatible with zero-based arrays of Char?
>
>It seems to work already ... my GPC just compiled:
>
>
> program foobar;
>
> {$X+}
>
> function foo ( p : pChar ) : pChar;
> Begin
> foo := succ ( p, 2 );
> End;
>
> Var
> x : array [ 0..4 ] of Char value 'xyOK'#0;
>
> Begin
> writeln ( foo ( x ) );
> End.
Yes, it does seem so. However, the following program
gives different outputs under BP and GPC;
program foobar;
{$ifdef ver70}
Uses Strings;
function puts ( astr : PChar ) : char;
begin
Writeln ( astr );
end;
{$else}
{$X+}
{$W-}
function strcopy ( s1 : PChar; s2 : PChar ) : PChar; asmname 'strcpy';
function strcat ( s1 : PChar; s2 : PChar ) : PChar; C;
function puts ( s1 : PChar ) : Integer; C;
{$endif}
function foo ( p : pChar ) : pChar;
Begin
foo := p + 2;
End;
Var
x : array [ 0..24 ] of Char;
Begin
strcopy(x, 'African');
strcat(x, #13#10);
strcat(x, 'Chief');
puts(x);
End.
Best regards, The Chief
Dr Abimbola A. Olowofoyeku (The African Chief, and the Great Elephant)
Author of: Chief's Installer Pro v3.60 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