Shorts Flashcards
Pointers
Provides an alternate way to pass on data between functions
In C we pass a copy of the data when we pass data by value
Is nothing more than an address to a location where the memory lives
HDD
hard disk drive
SSD
solid-state drive
pointer is a data item whose
value is a memory address
type describes the data located at that memory address
pointer
can update variables
NULL
if no value for the pointer set it to this
How to create a pointer
extract the address of an already existing var
& address extraction operator
if x is the variable
then &x is a pointer who is valued at the address of x
&arr[i] is a pointer to double an array of doubles it uses the ith element
dereferencing
inspect or modify the location of which it points
pointer-to-char
*pc data lives inside pc
*
dereferencing operator
knowing the address but not going there
That’s, where * comes in u, go there
Dynamic Memory Allocation
every block that you malloc() must subsenquely be free() d
only memory that you malloc() musy be free()d
do not free() a memory block more then once
Segmentation Fault
Trying to acces memory that is not meant to be touched