Wiki source for KeyPgCptr


Show raw source

{{fbdoc item="title" value="CPTR"}}----
Converts a pointer expression to a specified data type pointer

{{fbdoc item="syntax"}}##
**Cptr**( //""PointerDataType""//, //expression// )
##
{{fbdoc item="desc"}}
Converts ##//expression//## to ##//""PointerDataType""//##.

##//""PointerDataType""//## must be a ##[[KeyPgPointer|Pointer]]## type (e.g. a [[DataType]] ##[[KeyPgPtr|Ptr]]## or an ##[[KeyPgAny|Any]]## ##[[KeyPgPtr|Ptr]]##), or a ##[[KeyPgTypeAlias|Type (Alias)]]## to one.
##//expression//## may have a different pointer type or be an ##[[KeyPgInteger|Integer]]##.

~&//Note: Currently, FB does not actually enforce that ##//""PointerDataType""//## must be a pointer. This will likely change in future versions though. Currently, it may display a warning if you try to convert to a non-pointer (for any conversion type if you compile with the ##**[[CompilerOptw|-w pedantic]]**## compiler switch).//

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/casting/cptr.bas"}}%%(freebasic)
dim intval as integer
dim intptr as integer ptr
intval = &h0080
intptr = @intval
'' will print -128 and 128, as the first expression will be "seen" as an signed byte
print *cptr( byte ptr, intptr ), *intptr
%%

{{fbdoc item="lang"}}
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Cptr""**##.

{{fbdoc item="diff"}}
- New to ""FreeBASIC""

{{fbdoc item="see"}}
- ##[[KeyPgPtr|Ptr]]##
- ##[[KeyPgCast|Cast]]##
- ##[[KeyPgCbyte|Cbyte]]##
- ##[[KeyPgCshort|Cshort]]##
- ##[[KeyPgCint|Cint]]##
- ##[[KeyPgClngint|Clngint]]##
- ##[[KeyPgCsng|Csng]]##
- ##[[KeyPgCdbl|Cdbl]]##

{{fbdoc item="back" value="CatPgCasting|Converting Data Types"}}
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode