Pointers: Part 1 Flashcards
1
Q
pointer
A
a variable whose value is a memory address
2
Q
Assign the address of var to a pointer ptr
A
ptr = &var;
3
Q
What does ptr = &val mean
A
ptr is a pointer variable of the same data type as val that stores the memory address of val
4
Q
What operator must be used to create a pointer variable?
A
The indirection/dereferencing (*) operator - it declares the datatype of the pointer variable
5
Q
What is the purpose of the indirection/dereferencing operator?
A
The * operator is used:
- to assign the value stored at the memory address pointed to by a pointer variable. E.g. - val = *ptr // finding the value ptr points to
- to declare a pointer variable. E.gs - int * pi, char * pc
6
Q
A
7
Q
A
8
Q
A