X hits on this document

170 views

0 shares

0 downloads

0 comments

33 / 63

Copyright ©2004 Pearson Addison-Wesley. All rights reserved.

8-33

Returning an Array from a function(2)

Type problem between int[] and int*

a is a constant pointer type, you can’t change it.

Array c is stored in function foo’s stack frame.

Return just copies the pointer, not the array.

Memory where the array c resides may be overwritten once function foo finishes its execution.

To do it properly

Pass an array as a function argument from your calling function and modify it inside the called function.

Document info
Document views170
Page views170
Page last viewedSat Dec 10 12:21:26 UTC 2016
Pages63
Paragraphs754
Words4119

Comments