Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String & PChar

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

I am trying to assign a PChar variable to a String Value,

eg,
Var
test1: PChar;
test2: String;
begin
test2 := 'This is a string';

I then want to do test1 := test2

but I get an error saying "Incompatible Types: 'String' and 'PChar'.

Anyone know how to get around this?

Thanks,

Barry
 
Hi

you may try this:

Var
test1: PChar;
test2: String;
begin
test2 := 'This is a string';
test1 := PChar(test2);

so you won't get that error;
 
Var
test1: PChar;
test2: String;
begin
test2 := 'This is a string';

test1 := StrNew(PChar(test2));

//now you have a pointer to the string!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top