X hits on this document

127 views

0 shares

0 downloads

0 comments

24 / 63

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

8-24

Using arrays in formal parameter list

void foo(int x[10]); // sized array

Store the address of the corresponding array argument (a in previous slide) to variable x and remember it as an array of 10 elements.

void foo(int x[]); // unsized array

The length of the array is not specified. Since it is not a copy , the compiler does not need to allocate space for the array and therefore does not need to know the size of the array.

With this, we can pass an array of any size to function foo.

void foo(int *x); // array pointer

Function foo can take any integer array as argument.

Document info
Document views127
Page views127
Page last viewedSat Dec 03 00:18:06 UTC 2016
Pages63
Paragraphs754
Words4119

Comments