[Courses] Re: pointers, array's, and sizeof()
coldfire
rolick571 at duq.edu
Sun Feb 3 02:10:02 EST 2002
> This means, that with three exceptions, (that they tell you about
> later) you can pretend that the name of an array is a pointer to the
> first thing in the array.
i.e. "pointer notation" ... if you declare an array of ten elements, this
for loop will print the elements of the array:
int array[10] = {1,2,3,4,5,6,7,8,9,0};
for (int i = 0; i < 10; i++) {
cout << *(array+i) << endl;
}
> What is myArray really? It's a pointer to a block of memory. that
> block of memory is the size of one element multiplied my the number of
> elements you have. if an int is 4 bytes (and I really don't remember
> how big an int is), than myArray points to a block of memory that is 40
> bytes big.
the size of 'int' really depends on the operating system ... i think the
most common size of an int is four bytes now ...
coldie
More information about the Courses
mailing list