{{fbdoc item="title" value="CLEAR"}}----
Clears or initializes some memory

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **Clear** [[KeyPgCdecl|cdecl]] ( [[KeyPgByref|byref]] //dst// [[KeyPgAs|as]] [[KeyPgAny|any]], [[KeyPgByval|byval]] //value// [[KeyPgAs|as]] [[KeyPgLong|long]] = 0, [[KeyPgByval|byval]] //bytes// [[KeyPgAs|as]] [[KeyPgUinteger|uinteger]] )
##
{{fbdoc item="usage"}}##
	**Clear**( //dst//, [//value//], //bytes// )
##
{{fbdoc item="param"}}
	##//dst//##
		starting address of some memory
	##//value//##
		the value to set all bytes equal to
	##//bytes//##
		number of bytes to clear

{{fbdoc item="desc"}}
	##**Clear**## sets one or more bytes in memory to a certain value (the default value is zero (##0##) if not specified). The starting address is taken from a reference to a variable or array element.
	
	**NOTE:** In order to clear memory referenced by a ##[[KeyPgPtr|Pointer]]##, it must be dereferenced first.  Otherwise, ##**Clear**## will try to clear the bytes at the **pointer variable**'s memory location.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/array/clear.bas"}}%%(freebasic)
'create an array with 100 elements
dim array(0 to 99) as integer

'clear the contents of the array to 0, starting with the first element
clear array(0), , 100 * sizeof(integer)


'allocate 20 bytes of memory
dim as byte ptr p = allocate(20)

'set each of the first ten bytes to 0
clear *p, 0, 10

'set each of the next ten bytes to 42
clear p[10], 42, 10

'check the values of the allocated bytes
for i as integer = 0 to 19
	print i, p[i]
next

'deallocate memory
deallocate p
%%

{{fbdoc item="diff"}}
	- The behavior and usage is new to ""FreeBASIC""
	- The keyword ##CLEAR## was used in QB to erase all variables, close all files, and optionally change the stack size. This use is not supported in ""FreeBASIC"".

{{fbdoc item="see"}}
	- ##[[KeyPgErase|Erase]]##
	- ##[[KeyPgReset|Reset]]##

{{fbdoc item="back" value="CatPgMemory|Memory Functions"}}