Chapter 7 - Pointers

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Pointers maybe assigned which of the following?

Address and NULL

If array name arrayName is passed to a function, c automatically passes

&arrayName[0]

Pointer/offset notation vs pointer/index notation vs areay of piintrr

*(b+3) // pointer/offset notation Also *(bPtr + 3) bPtr[3] // pointer index b[3] // array indexing

If bPtr is assigned b ( the name of an array) then array element b[3] can alternatively be referenced with the pointer expression

*(bPtr + 3)

Three of the following expressions have the same value. Which one of the following values is different from the others?

*Ptr

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

++

Pointer arithmetic and how to use it

++, - -, +, +=, -, -=

What values can be assigned to a pointer?

0, null, and address

What are the 4 ways to pass a pointer to a function?

A non-constant pointer to non-constant data A non-constant pointer to constant data A constant pointer to non-constant data (array) A constant pointer to constant data

The * symbol means:

All of the answers (unary indirection operator for pointer, "pointer to" in a formal par list, multiplication of operands)

4 methods for referring to array elements

Array indexing Pointer/offset with the array name as a pointer Pointer indexing Pointer/offset with a pointer

All operators normally used in arithmetic expression, assignment expressions and comparison expressions are valid in conjunction

False

Assume int b[5]; int *bPtr; bPtr = b; To refer to an array element, the notations *bPtr + 3 and bPtr[3] are interchangeable.

False

Function prototypes may not be placed inside functions

False

Accessing the contents of memory using a pointer variable that contains the address of that memory location is called:

Indirect reference

Pointers are variables that contain__as their values

Memory addresses

Pointers cannot be used to

Reference values directly

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

int * a

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

&t[3]

What is the sizeof operator and how to use it?

It determines sizes in bytes of a variable or an array at compilation time. When applied to the name of an array sizeof returns the total number of bytes in the array as type size_t. Eg. Sizeof c, sizeof(char) Double = 8 bytes Float = 4 bytes Int = 4 Long = 4 Short = 2 Char = 1 Eg. double real[22]; // 22 * 8 = 176 so sizeof is 176 and # of elements is sizeof/double bytes = 22

The highest level of data access is granted by a

Non-constant pointer to non-constant data

A function that prints a string should have a parameter that's a

Nonconstant pointer to constant data

What's the indirection operator * ?

Or dereferencing operator, can be used in 2 ways: In a declaration to declare a pointer (in this case it's not a dereferencing operator). In a printf("%d", *yPtr); //in this case it's a dereferencing operator.

What is a pointer?

Pointers are variables whose values are memory addresses.

sizeof

Returns the total number of bytes in an array

Which statement is false?

Structures are always passed call by reference

Comparing pointers and performing arithmetic on them is meaningless unless

They point to members of the same array

How to use the & operator?

To indicate that's the address of the variable being passed


Kaugnay na mga set ng pag-aaral

GRE Subject Test: Literature in English Notes

View Set

Chapter 27 Development and Heredity

View Set

History Study Guide Chapters 15-18

View Set

Finance Chapter 8: Managing Credit

View Set

English 12B Unit 5: Dawning of a New Era (Modern Period, 1901-Present)

View Set

Biochem 501 Final exam, Biochem 501 Unit 4, Biochem Unit 2

View Set