home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_08 / 1108114a < prev    next >
Text File  |  1993-06-08  |  334b  |  25 lines

  1. /* swap2.c: A working swap function */
  2. #include <stdio.h>
  3.  
  4. void swap(int *, int *);
  5.  
  6. main()
  7. {
  8.     int i = 7, j = 8;
  9.     
  10.     swap(&i,&j);
  11.     printf("i == %d, j == %d\n",i,j);
  12.     return 0;
  13. }
  14.  
  15. void swap(int *xp, int *yp)
  16. {
  17.     int temp = *xp;
  18.     *xp = *yp;
  19.     *yp = temp;
  20. }
  21.  
  22. /* OUTPUT:
  23.  * i == 8, j == 7 */
  24.  
  25.