home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_11 / 8n11103a < prev    next >
Text File  |  1990-08-09  |  1KB  |  49 lines

  1.  
  2. ***********
  3. Listing 3     
  4.  
  5. #include <stdio.h>
  6.  
  7. typedef   struct
  8.           {
  9.           char      fname[25];
  10.           char      lname[25];
  11.           } REC;
  12.  
  13. main()
  14.      {
  15.      REC  rec, *recptr;
  16.      char charstr[25], *cptr;
  17.      int  i;
  18.  
  19.           /***********/
  20.  
  21.      strcpy(rec.fname, "Stanley");
  22.      strcpy(rec.lname, "Cohen");
  23.  
  24.      recptr = &rec;
  25.      cptr = recptr;      /*** value of recptr is assigned to cptr
  26.                               NO cast ***/
  27.  
  28.      i = 0;;
  29.      while( charstr[i++] = *cptr++);    /*** pointer arithmetic 
  30.                                              on cptr ***/
  31.  
  32.      puts(charstr);      /***   first name is output to screen 
  33.                                                        ***/
  34.  
  35.      cptr = recptr;
  36.  
  37.      printf("\n\address pointed to by cptr -> %d", cptr);
  38.      printf("\naddress pointed to by recptr -> %d", recptr);
  39.  
  40.      cptr++;
  41.      recptr++;
  42.  
  43.      printf("\n\naddress pointed to by cptr -> %d", cptr);
  44.      printf("\naddress pointed to by recptr -> %d", recptr);
  45.  
  46.     }
  47. **********
  48.  
  49.