Electrical and Computer Engineering
10
of 17
UAH
CPE 112
Preventing the Function
from Modifying an Array
•
Use the reserved word
const
.
•
Example:
•
void
Copy(
/* out */
int
destination[],
•
/* in */
const
int
source[],
•
/* in */
int
size)
•
{
•
int
i;
•
for
(i = 0; i < size; i++)
•
destination[i] = source[i];
•
}