10 - Pointers and Dynamic Arrays Flashcards

1
Q

What is a pointer?

A

A pointer is the memory address of a variable.

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

Explain the meaning of this: double *p

A

Declares p to be a pointer variable that can hold one pointer that points to a variable of type double.

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

How do you declare a pointer?

A

Type_Name *Variable_Name1, *Variable_Name2, … ;

Example:
double *pointer1, *pointer2;

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

A pointer is an address. T/F?

A

T!

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

An adress in an integer. T/F?

A

T!

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

A pointer is an integer. T/F?

A

F! A pointer is an address, an address in an integer, but a pointer in not an integer.

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

How do you store an address in a pointer?

A

int* p1;
v1 = 0;
p1 = &v1;

The pointer variable, p1, now points to the address of v1.

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

What is wrong with this?

int* p1, *p2;

A

It can lead to confusion. Both p1 and p2 are now pointer variables, but the correct way to write this would be:

int *p1, *p2;

But for me, placing the asterix on the type is the best way. That means this should be written as:

int* p1;
int* p2;

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

What is the dereferencing operator?

A

The * in front a a pointer variable. It produces the variable to which it points.

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

What is the “address of operator”?

A

The & operator.

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