ECS 30 Lecture Notes - Lecture 8: Scanf Format String, Null Character, Segmentation Fault

33 views2 pages

Document Summary

No matter how you give a function an array, it will always be received as a pointer variable. This is regardless of how the array is passed (int* or int[]). This is necessary to explicitly pass the array size. Gcc warns when using sizeof() on a decayed array. When passing the array we are giving it a reference of the array, whenever you give the array you should give the size as well. If you return the address of the local variable a segmentation fault is likely as you will try to reference a variable that does not exist anymore. You can return variables from functions, but the memory addresses will disappear. Searching and sorting arrays are two of the most common array problems. You can use returns of different values to encode different types of information. Returning the index of the array is a good way to search something.

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