Pointers Flashcards

1
Q

what is a pointer

A

is a variable whose value is a memory address
A memory address is just an integer value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why do we need pointers?

A

for the sake of space and
time efficiency.
e.g, an array of 1000 elements, instead passing it to a function by value,automatic allocation , which may use up all the stack space.
pass

So the address stored in the pointer variable
would be passed by value, and thus copied into the function’s stack frame

they are the only way we can create more complex data
structures in C such as linked lists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  • for types
    type*
A

int main () {
int * pointerToInteger ;
float * pointerToFloat ;
double * pointerToDouble ;
return 0;
}

this is not a unary Application
pointer to type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Storage Allocation for Pointer Variables

A

A pointer defined as a local variable gets automatically allocated
space for its address, and let’s say that it is initialized to the address 424242. However, the
memory at address 424242 might have been allocated with any allocation method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

&

A

Used to get the memory address of a variable.
this is an unary application

int main () {
int ultimateAnswer = 42
int* pointerToUltimate ;
pointerToUltimate = &ultimateAnswer ;
return 0;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

deferencing

A

the process of “following” a pointer and obtaining or changing the value in the memory location to which it “points”.

The dereferencing operator in C is the unary * operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Using Dereferencing to Obtain the Value at the Referenced Memory Location

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Using Dereferencing to Modify the Value at the Referenced Memory Location

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

difference in assignments

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Precedence

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly