Just wait until you get to pointers.
Arrays aren't that hard...its probably because you haven't had to use them yet.
Here's a basic example with some - say I want to print out three numbers. You'd say well make three int variables.
Code:
int i1, i2, i3;
cout << i1 << i2 << i3;
But what about 5?
Code:
int i1, i2, i3, i4, i5;
cout << i1 << i2 << i3 << i4 << i5;
100?
Code:
int i1, i2, i3, i4, i5, i6, i7, i8...
cout << i1 << i2 << i3 << i4 << i5 << i6...
Exactly. Simple make an array of 100 size
Code:
int i[99]; //remember, computers count from 0, so this is the correct size
and use a for loop to print them out.
so here is an example. it both initializes and prints an array of ones.
Code:
#include <iostream>
int main() {
int i[99], x;
for(x=0;x<100;x++) {
i[x] = 1; //reference member 'x' of array i
}
for(x=0;x<100;x++) {
cout << i[x] << endl;
}
return 0;
}