Operator Strptr (String Pointer)

Returns the address of a string's character data.

Syntax
	KeyPgDeclareDeclare KeyPgOperatorOperator StrPtr ( KeyPgByrefByRef lhs KeyPgAsAs KeyPgStringString ) KeyPgAsAs KeyPgZstringZString KeyPgPtrPtr
	KeyPgDeclareDeclare KeyPgOperatorOperator StrPtr ( KeyPgByrefByRef lhs KeyPgAsAs KeyPgWstringWString ) KeyPgAsAs KeyPgWstringWString KeyPgPtrPtr

Usage
	result = StrPtr ( lhs )

Parameters
	lhs
		A string.

Return Value
	Returns a KeyPgZstringZString/KeyPgWstringWString KeyPgPtrPtr to a string/wstring's character data (null 
	value in case of empty string).

Description
	This operator returns a KeyPgZstringZString/KeyPgWstringWString KeyPgPtrPtr that points to the beginning 
	of a string/wstring's character data. Operator Strptr is the proper 
	method for acquiring the address of a string's character data.
	In case of empty KeyPgStringString (only for variable length strings), Operator 
	Strptr returns a null pointer.

	The related KeyPgOpVarptrOperator Varptr (Variable Pointer) and 
	KeyPgOpAtOperator @ (Address Of), when used with a KeyPgStringString, return the address of 
	the internal string descriptor.
	When a variable length string is modified, the address of its descriptor 
	remains always the same, but the the string's character data address 
	(returned by Operator Strptr) may change (like any allocated memory that 
	must be reallocated).
	When a fixed length string is modified, the string's character data 
	address (returned by Operator Strptr) is unchanged.

	Note: For a variable length string, the operator returns a KeyPgZstringZString KeyPgConstQualifierConst 
	KeyPgPtrPtr (because returning by reference the string's characters pointer set 
	in the string descriptor, this one is to be considered as read only). If 
	the keyword KeyPgVarVar is used to declare/initialize a user pointer from 
	Operator Strptr, this user pointer is also defined as read only (it can 
	not be modified further).

	Warning: Since fbc version 1.20.0, dereferencing a zstring pointer to a 
	fixed-length string of STRING*N type (which no longer has an additional 
	terminal null character as before) can lead to an extension of the 
	string by some pollution, or even an outright crash.

Example
	'' This example uses Strptr to demonstrate using pointers with strings
	Dim myString As String
	Dim toMyStringDesc As Any Ptr
	Dim toMyString As ZString Ptr

	'' Note that using standard VARPTR notation will return a pointer to the
	'' descriptor, not the string data itself
	myString = "Improper method for Strings"
	toMyStringDesc = @myString
	Print myString
	Print Hex( toMyStringDesc )
	Print

	'' However, using Strptr returns the proper pointer
	myString = "Hello World Examples Are Silly"
	toMyString = StrPtr(myString)
	Print myString
	Print *toMyString
	Print

	'' And the pointer acts like pointers to other types
	myString = "MyString has now changed"
	Print myString
	Print *toMyString
	Print

Differences from QB
	* New to FreeBASIC, but does exactly the same thing as KeyPgSaddSAdd

See also
	* KeyPgSaddSAdd
	* KeyPgOpVarptrVarPtr
	* KeyPgOpProcptrProcPtr
	* ProPgPointersPointers

