Skip to main content
Minor edit: grammar/spelling/case/punctation/etc.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

The array name by itself yields a memory location, so you can treat the array name like a pointer:

int a[7]; a[0] = 1976; a[1] = 1984; printf("memory location of a: %p", a); printf("value at memory location %p is %d", a, *a); 

andAnd other nifty stuff you can do to pointer  (e.g. adding/substracting an offset), you can also do to an array:

printf("value at memory location %p is %d", a + 1, *(a + 1)); 

languageLanguage-wise, if C didn't expose the array as just some sort of "pointer"(pedantically it's just a memory location, it. It cannot point to arbitrary location in memory, nor can be controlled by the programmer), we. We always need to code this:

printf("value at memory location %p is %d", &a[1], a[1]); 

array name by itself yields a memory location, so you can treat the array name like a pointer:

int a[7]; a[0] = 1976; a[1] = 1984; printf("memory location of a: %p", a); printf("value at memory location %p is %d", a, *a); 

and other nifty stuff you can do to pointer(e.g. adding/substracting an offset), you can also do to array:

printf("value at memory location %p is %d", a + 1, *(a + 1)); 

language-wise, if C didn't expose the array as just some sort of "pointer"(pedantically it's just a memory location, it cannot point to arbitrary location in memory, nor can be controlled by the programmer), we always need to code this:

printf("value at memory location %p is %d", &a[1], a[1]); 

The array name by itself yields a memory location, so you can treat the array name like a pointer:

int a[7]; a[0] = 1976; a[1] = 1984; printf("memory location of a: %p", a); printf("value at memory location %p is %d", a, *a); 

And other nifty stuff you can do to pointer  (e.g. adding/substracting an offset), you can also do to an array:

printf("value at memory location %p is %d", a + 1, *(a + 1)); 

Language-wise, if C didn't expose the array as just some sort of "pointer"(pedantically it's just a memory location. It cannot point to arbitrary location in memory, nor can be controlled by the programmer). We always need to code this:

printf("value at memory location %p is %d", &a[1], a[1]); 
added 4 characters in body; added 2 characters in body
Source Link
Michael Buen
  • 39.6k
  • 10
  • 99
  • 120

array name by itself yields a memory location, so you can treat the array name like a pointer:

int a[7]; a[0] = 1976; a[1] = 1984; printf("memory location of a: %p", a); printf("value at memory location %p is %d", a, *a); 

and other nifty stuff you can do to pointer(e.g. adding/substracting an offset), you can also do to array:

printf("value at memory location %p is %d", a + 1, *(a + 1)); 

language-wise, if C didn't expose the array as just some sort of "pointer"some sort of "pointer"(pedantically it's just a memory offsetlocation, it cannot point to arbitrary location in memory, nor can be controlled by the programmer), we always need to code this:

printf("value at memory location %p is %d", &a[1], a[1]); 

array name by itself yields a memory location, so you can treat the array name like a pointer:

int a[7]; a[0] = 1976; a[1] = 1984; printf("memory location of a: %p", a); printf("value at memory location %p is %d", a, *a); 

and other nifty stuff you can do to pointer(e.g. adding/substracting an offset), you can also do to array:

printf("value at memory location %p is %d", a + 1, *(a + 1)); 

language-wise, if C didn't expose the array as just some sort of "pointer"(pedantically it's just a memory offset, it cannot point to arbitrary location in memory, nor can be controlled by the programmer), we always need to code this:

printf("value at memory location %p is %d", &a[1], a[1]); 

array name by itself yields a memory location, so you can treat the array name like a pointer:

int a[7]; a[0] = 1976; a[1] = 1984; printf("memory location of a: %p", a); printf("value at memory location %p is %d", a, *a); 

and other nifty stuff you can do to pointer(e.g. adding/substracting an offset), you can also do to array:

printf("value at memory location %p is %d", a + 1, *(a + 1)); 

language-wise, if C didn't expose the array as just some sort of "pointer"(pedantically it's just a memory location, it cannot point to arbitrary location in memory, nor can be controlled by the programmer), we always need to code this:

printf("value at memory location %p is %d", &a[1], a[1]); 
Source Link
Michael Buen
  • 39.6k
  • 10
  • 99
  • 120

array name by itself yields a memory location, so you can treat the array name like a pointer:

int a[7]; a[0] = 1976; a[1] = 1984; printf("memory location of a: %p", a); printf("value at memory location %p is %d", a, *a); 

and other nifty stuff you can do to pointer(e.g. adding/substracting an offset), you can also do to array:

printf("value at memory location %p is %d", a + 1, *(a + 1)); 

language-wise, if C didn't expose the array as just some sort of "pointer"(pedantically it's just a memory offset, it cannot point to arbitrary location in memory, nor can be controlled by the programmer), we always need to code this:

printf("value at memory location %p is %d", &a[1], a[1]);