Chapter 8

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

. Is a call to the function pointed to by max.

(*max)(num1, num2, num3);:

2012

: Given that k is an integer array starting at location 2000, kPtr is a pointer to k and each integer is stored in 4 bytes of memory, what location does kPtr + 3 point to?

cin.getline(superstring, 30, '\n');

: cin.getline(superstring, 30);

The built-in array parameter can be preceded by the const qualifier

:To prevent modification of a built-in array's values when you pass the built-in array to a function:

A nonconstant pointer to nonconstant data.

A function that modifies an array by using pointer arithmetic such as ++ptr to process every value of the array should have a parameter that is:

A nonconstant pointer to constant data.

A function that prints a string by using pointer arithmetic such as ++ptr to output each character should have a parameter that is:

A pointer of a type other than its own type and void without using the cast operator.

A pointer can not be assigned to:

Command-line arguments

A string array is commonly used for:

Is actually an array of pointers.

A string array:

Dereferencing a variable that is not a pointer. (This is a compilation error.)

All of the following can cause a fatal execution-time error except

&t[3]

Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the array?

They point to elements of the same array.

Comparing pointers and performing pointer arithmetic on them is meaningless unless:

Pointer/offset notation.

Consider the following function: void reverse(char *string1, const char *string2) { int stringsize{sizeof(string1)/sizeof(char)}; *(string1 + stringsize - 1) = '\0'; string1 = string1 + stringsize - 2; for (; *string2 != '\0'; string1--, string2++) { *string1 = *string2; } } What technique does the function use to refer to array elements?

sort(begin(values), end(values));

Given a built-in array of ints named values, which of the following statements would sort the array?

. Reference values directly

Pointers cannot be used to:

Both (b) and (c).

Pointers may be assigned which of the following values?

lvalues

The & operator can be applied to

c. *ptr

Three of the following expressions have the same value. Which of the following expressions has a value different from the others'?

One pointer to an int and one int variable

What does the following statement declare?

A constant pointer to constant data.

What method should be used to pass an array to a function that does not modify the array and only looks at it using array subscript notation

int * a

When a compiler encounters a function parameter for a single-subscripted array of the form int a[], it converts the parameter to

n is a constant pointer to nonconstant data.

Which of the following best describes the array name n in the declaration int n[10];?

++

Which of the following can have a pointer as an operand?

sizeof r / sizeof (int)

Which of the following gives the number of elements in the array int r[10]?

It always knows the size of the built-in array that is being passed.

Which of the following is false about a function to which a built-in array is being passed?

String literals are written inside of single quotes

Which of the following is false for pointer-based strings?

int n[5]{0, 7, 0, 3, 8, 2};

Which of the following is not a correct way to initialize a built-in array?

By value with pointer arguments.

Which of the following is not a valid way to pass arguments to a function in C++?

They can not be assigned to other function pointers.

Which of the following is not true of pointers to functions?

In the new standard, you should use the constant null_ptr to initialize a pointer instead of 0 or NULL. [The constant is actually nullptr (without the underscore).]

Which of the following statements about pointer initialization and values is false?

int c[10];

Which statement would be used to declare a 10-element integer array c?

. Returns the total number of bytes in a variable.

sizeof:


Ensembles d'études connexes

NURS 302 Mental Health 2: Exam 1

View Set

Chapter 34 - The Child with Musculoskeletal or Articular Dysfunction

View Set