hw6 - Homework 6 (4-16) 4. (Ch.10, Problem 1) Find any...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 6 (4-16) 4. (Ch.10, Problem 1) Find any errors in the following C program. Give a brief rationale if there is any error. int funct1(int *p) { There is a logic error; there's no reason to point to the address in front of int i = -1; the semicolon ( ; ). The program could break because it is not an array. int *pp; pp = p+1; return pp; } int main() { int i = 5; funct1(i); The function called is pointing to another pointer; the pointer should be } pointing to the integer ( p to i ). Also, the address of i ( ) is required. 5. (Ch.10, Problem 3) State whether the following are true or false. If false, explain why. a.) Two pointers that point to different arrays cannot be compared meaningfully. True. b.) Because the name of an array is a pointer to the first element of the array, array names may be manipulated in precisely the same manner as pointers. False; with pointers, you can point to any element in the array, but with arrays, you cannot. 6. (Ch.10, Problem 6)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

hw6 - Homework 6 (4-16) 4. (Ch.10, Problem 1) Find any...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online