home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / ctutor2.zip / POINTER2.C < prev    next >
Text File  |  1989-11-10  |  1KB  |  43 lines

  1.                                          /* Chapter 8 - Program 2 */
  2. #include "stdio.h"
  3. #include "string.h"
  4.  
  5. void main()
  6. {
  7. char strg[40],*there,one,two;
  8. int *pt,list[100],index;
  9.  
  10.    strcpy(strg,"This is a character string.");
  11.  
  12.    one = strg[0];                    /* one and two are identical */
  13.    two = *strg;
  14.    printf("The first output is %c %c\n",one,two);
  15.  
  16.    one = strg[8];                   /* one and two are indentical */
  17.    two = *(strg+8);
  18.    printf("the second output is %c %c\n",one,two);
  19.  
  20.    there = strg+10;      /*   *(strg+10) is identical to strg[10] */
  21.    printf("The third output is %c\n",strg[10]);
  22.    printf("The fourth output is %c\n",*there);
  23.  
  24.    for (index = 0;index < 100;index++)
  25.       list[index] = index + 100;
  26.    pt = list + 27;
  27.    printf("The fifth output is %d\n",list[27]);
  28.    printf("The sixth output is %d\n",*pt);
  29. }
  30.  
  31.  
  32.  
  33. /* Result of execution
  34.  
  35. The first output is T T
  36. The second output is a a
  37. The third output is c
  38. The fourth output is c
  39. The fifth output is 127
  40. The sixth output is 127
  41.  
  42. */
  43.