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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I get round the string copy-on-write technique? 1

Status
Not open for further replies.

sancho1980

Technical User
Nov 25, 2005
15
DE
Hi, I'm very new to Pascal and I'm actually learning it because I need to do something in Delphi. I've worked with C and JAVA before where I wouldn't have had to ask this question actually: As I understand it, if you have a string variable in Pascal referenced by 2 variables and then change the content of the string via one of these 2 variables, a new string is created leaving the old string untouched. This means that the other variable still references the unchanged string. Now, waht if I don't want that? What can I do if I want to change my string without creating a new one, i.e. if I want the other variable to reference the changed string as well?
Regards,
Martin
 
Code:
var
  a:string;
  b:pansistring;

begin
  a:='hello';
  b:=@a;
  a:='world';
  ShowMessage(b^);
end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top