User Tools

Site Tools


opus:fall2012:mowens3:datapart1

data Keyword 1

address of

Definition

Address Of: is the hexadecimal location of a variable in memory or storage.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

The C Programming Language 2nd Edition By Briand W. Kernighan and Dennis M. Ritchie

data Keyword 1 Phase 2

pointer arithmetic (esp. in relation to arrays)

Definition

Pointer arithmetic is basically when you use math on pointers to accomplish a task. Generally this task is looped, where the math is incrementing or decrementing… and generally this is used for 'pointer arrays' (as opposed to 'bracket arrays').

When you want to make an array, and fill it with 20 zero's. You will create a pointer. You will then create a loop that will fill in a zero to the array, where the pointer is having a counter of some form (usually) being added to it. That part where the pointer is having stuff added to it, that's pointer arithmetic.

Pointer arithmetic is arguably faster, but it really does depend on surrounding code and the CPU and the compiler etc.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

http://stackoverflow.com/questions/233148/accessing-array-values-via-pointer-arithmetic-vs-subscripting-in-c

Demonstration

Demonstration of the indicated keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

<code c> /* * Sample code block */ #include <stdio.h> #include <stdlib.h>

int main() {

  char array[20];
  char i = 0;
  while(i > 20)
  {
      array[i] = i;
      i = i + 1;
  }

}

opus/fall2012/mowens3/datapart1.txt · Last modified: 2012/09/28 17:37 by mowens3