Abstract
Enough about general considerations for arrays and pointers—it is time we see how we use both in practice. I will start by showing a few examples of how we can solve some selected problems using both arrays and pointers and illustrate how closely related the two things are. Quite often, the code you write to operate on an array is the same as the code you write to operate on pointers, even when you do not use pointers plus offsets (which is, after all, exactly what we do when we use the array syntax). In an attempt to make it at least appear that we are working with two different types of objects, I will use different conventions for the functions in this section. Functions with array arguments will have the type
rettype function(int n, type array[n]);
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
The static_assert macro was introduced in C11, so if your compiler doesn’t support it, just delete the line. It is unlikely that your integer type should have an odd size.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2021 Thomas Mailund
About this chapter
Cite this chapter
Mailund, T. (2021). Working with Arrays. In: Pointers in C Programming. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-6927-5_6
Download citation
DOI: https://doi.org/10.1007/978-1-4842-6927-5_6
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-6926-8
Online ISBN: 978-1-4842-6927-5
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books