Lazarus

Free Pascal => Beginners => Topic started by: JLWest on April 01, 2023, 01:32:45 am

Title: StrComp problem(Solved)
Post by: JLWest on April 01, 2023, 01:32:45 am
Trying to compare two strings;
I don't understand what wrong with this.
Didn't know it mattered.
It compiled. I haven't tested it yet.

Sometimes just sName=sTag works and sometimes not. Wonder why?

Code: Pascal  [Select][+][-]
  1. VAR
  2.  P1 : PChar;
  3.  P2 : PChar;  
  4.  C: SizeInt;
  5. aName,aTag: String;
  6. begin
  7.  
  8. P1:=sName;             <<<duplicates.pas(243,10) Error: Incompatible types: got "AnsiString" expected "PChar"
  9. p2:=sTag;
  10. C:= strcomp(P1,P2);
  11.  
Title: Re: StrComp problem
Post by: KodeZwerg on April 01, 2023, 01:36:55 am
I do not know why you hide your declaration of sName, anyway, "P1 := PChar(sName);" should solve your issue.
TinyPortal © 2005-2018