Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert pchar space into integer value in delphi?
How to convert pchar space into integer value in delphi?
Before delphi 2009, PCchar refers to UnicodeChar with a size of 2 bytes instead of 1 byte. In order to ensure the same compilation effect of each version, Char should not be considered as 1 byte. For your question, you can directly increase PInt1after the disposal right of PChar is handed over to Pint. The safe writing is as follows:

I: integer;

p:PChar;

Pinter: pinger

......

pint:= PInteger(P);

//If you get the following loop final value when applying for memory, use it. If the data length is uncertain, use the following formula to calculate, but there must be #0 at the end of the data.

for I:= 1 to Length(string(P))* SizeOf(Char)div 4 do

begin

//Handle pint^, which is a 32-bit integer.

......

Inc (pint);

End;