<!-- hamlet
<!-- copytar
examples/                                                                                           0040755 0002611 0000666 00000000000 06355553667 0013552 5                                                                                                    ustar 00hamlet                          hamlet                          0000235 0000202                                                                                                                                                                        examples/parith.c                                                                                   0100644 0002611 0000666 00000001003 06355553664 0015171 0                                                                                                    ustar 00hamlet                          hamlet                          0000235 0000202                                                                                                                                                                        /* level 4 */
/* Illustrates pointer arithmetic

Created:  Joe Zachary, November 14, 1992
Modified:
*/

#include <stdio.h>


/* We create two pointers and then look at the results of
   performing pointer arithmetic upon them. */

void main () {

  char c;
  int n;
  int i;

  char *p1 = &c;
  int *p2 = &n;

  for (i=0; i<4; i++)
    {
      printf("p1 + %d = %u\n", i, (unsigned) (p1+i));
    }
  
  printf("\n");

  for (i=0; i<4; i++)
    {
      printf("p2 + %d = %u\n", i, (unsigned) (p2+i));
    }
}

  
  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             examples/cptr1.c                                                                                    0100644 0002611 0000666 00000000450 06355553664 0014740 0                                                                                                    ustar 00hamlet                          hamlet                          0000235 0000202                                                                                                                                                                        /* level 4 */
/* Illustrates unitialized pointers

Created:  Joe Zachary, November 15, 1992
Modified:
*/

#include <stdio.h>


void main () {

  char *s;
  printf("Please enter a nice long string\n");
  gets(s);

  printf("Here is the string that you entered:\n");
  printf("%s\n", s);

}

  
  
                                                                                                                                                                                                                        examples/parray.c                                                                                   0100644 0002611 0000666 00000000747 06355553665 0015217 0                                                                                                    ustar 00hamlet                          hamlet                          0000235 0000202                                                                                                                                                                        /* level 4 */
/* Illustrates pointer arithmetic

Created:  Joe Zachary, November 14, 1992
Modified:
*/

#include <stdio.h>


/* We create two pointers and then look at the results of
   performing pointer arithmetic upon them. */

void main () {

  int i;

  char p1[4];
  int p2[4];

  for (i=0; i<4; i++)
    {
      printf("&p1[%d] = %u\n", i, (unsigned) &p1[i]);
    }
  printf("\n");

  for (i=0; i<4; i++)
    {
      printf("&p2[%d] = %u\n", i, (unsigned) &p2[i]);
    }
}

  
  
                         examples/cptr.c                                                                                     0100644 0002611 0000666 00000000300 06355553664 0014651 0                                                                                                    ustar 00hamlet                          hamlet                          0000235 0000202                                                                                                                                                                        /* level 4 */
/* Illustrates constant pointers

Created:  Joe Zachary, November 14, 1992
Modified:
*/

#include <stdio.h>


void main () {

  int A[10];
  int *p;

  p = A;
  A = p;

}

  
  
                                                                                                                                                                                                                                                                                                                                examples/rptr.c                                                                                     0100644 0002611 0000666 00000000560 06355553665 0014701 0                                                                                                    ustar 00hamlet                          hamlet                          0000235 0000202                                                                                                                                                                        /* level 4 */
/* Illustrates dangling pointers.

Created:  Joe Zachary, November 14, 1992
Modified:
*/

#include <stdio.h>


/* This function returns a pointer to five integers. */

int *example () {
  int A[5] = {1, 2, 3, 4, 5};
  return(A);
}


void main () {
  int i;
  int *B = example();

  for (i=0; i<5; i++)
    {
      printf("%d\n", B[i]);
    }
}
  

  
  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                