Jump to: navigation, search

Week 3

664 bytes added, 12:49, 26 May 2010
no edit summary
The real difference is that when you add one to a pointer, it doesn't just add one, it adds 4 bytes (it wants to go to the next integer in memory - or 8 bytes for double, etc). Pointer rithmetic
An array int a[10] will create 10 integers, and then create a pointer to the beginning of that list of integers.
*b = where b is pointing to
&a = the address of a
int* = pointer
a[0] is the same as *a. they are the same.
when you move one integer in the array
a[1] it moves 4 bytes over to the next integer.
Arrays are nothing buy pointers.
After creating an array you can just refer to it as "a" when wanting to get the pointer.
In creating 2D arrays, the pointer for the array is created to be as large as 1 array, so when you say a+1 it skips the entire first array and goes to the next one.
point notation:

Navigation menu