X hits on this document

201 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 views201
Page views201
Page last viewedThu Jan 19 00:17:05 UTC 2017
Pages63
Paragraphs754
Words4119

Comments