lesson 11 swapvals c
[[lesson_11_swapvals_c]] last edit on Aug 18, 2005 6:54 AM by rescued_by_c

[user02@FC4 Lesson11]$ cat -n swapvals.c
   1  #include <stdio.h>
   2
   3  void swap_values(float *a, float *b)
   4  {
   5     float temp;
   6
   7     temp = *a;
   8     *a = *b;
   9     *b = temp;
  10  }
  11
  12  int main(void)
  13  {
  14     float big = 10000.0;
  15     float small = 0.00001;
  16
  17     swap_values(&big, &small);
  18
  19     printf("Big contains %f\n", big);

  20     printf("Small contains %f\n", small);
  21
  22     return 0;
  23  }
[user02@FC4 Lesson11]$ gcc -o swapvals swapvals.c
[user02@FC4 Lesson11]$ ./swapvals
Big contains 0.000010
Small contains 10000.000000
[user02@FC4 Lesson11]$