xHarbour Reference Documentation > Function Reference |
Obtains the pointer for a character string.
HB_String2Pointer( <cString> ) --> pPointer
The function returns the pointer (memory address) of the passed string as a Poiner value (Valtype()=="P").
The function obtains the memory address of the character string <cString> and returns it as a Pointer value.
See also: | C Structure class, HB_Pointer2String() |
Category: | Pointer functions , xHarbour extensions |
Source: | rtl\str2ptr.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example converts a string to a pointer, voids the string // variable, and reads the string back from the pointer. PROCEDURE Main LOCAL cString := "Hello World" LOCAL pString := HB_String2Pointer( cString ) LOCAL nBytes ? Valtype( cString ), cString // result: C Hello World ? Valtype( pString ), pString // result: P 004b100a nBytes := Len( cString ) cString := NIL ? Valtype( cString ), cString // result: U NIL ? Valtype( pString ), pString // result: P 004b100a cString := HB_Pointer2String( pString, nBytes ) ? Valtype( cString ), cString // result: C Hello World ? Valtype( pString ), pString // result: P 004b100a RETURN
http://www.xHarbour.com