October 2004
Beginner
408 pages
9h 24m
English
You can initialize arrays (assign values to them) in one of two ways. First, you can do it one element at a time. Second, you can assign all of the values when declaring the array (just as you can assign values to any variable when you declare it). Let's go over both approaches in more detail.
Assigning values to array elements is similar to assigning values to any other variable: you use the assignment operator. The one distinct difference is that you must indicate the index to which the assigned value should apply. But first, a quick word about indexes in C.
Strange as it may seem, arrays in C are indexed beginning at 0. So the first element in an array called answers is answers[0] ...
Read now
Unlock full access