ECS 30 Lecture 13: ESC 030 Lecture 13 - Arrays Continued

21 views3 pages
Monday, 30 April 2018
ECS 030 - Lecture 13
Arrays Continued
Passing array as arguments
-Arrays always decay into simple pointers
when passed as arguments
Regardless of how the array is passed (int *
or int [ ])
Only way to explicitly pass the array
-GCC warns when using sizeof() on
a"decayed" array
decayed array - array that only has a value,
and address cannot be read since you are
referring to a pointer
-pointer has no address, it uses the
address of the variable it points to
Stack’s point of view
-Functions always
modify the original
arrays
1
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Arrays always decay into simple pointers when passed as arguments: regardless of how the array is passed (int * or int [ ], only way to explicitly pass the array. Gcc warns when using sizeof() on adecayed array: decayed array - array that only has a value, and address cannot be read since you are referring to a pointer. Pointer has no address, it uses the address of the variable it points to. Cannot return a local array from a function: all local variables disappear when a function returns, array becomes unusable. You can write a function to search for a particular element in an array, and nd ts location in it: useful to remember how the function operates, code is provided. Initialisation by rows of columns, with extra pairs of braces: imagine it as if there are arrays inside of the arrays, indicated by a second bracket. Functions need to know the number of columns per rows.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents