lesson 11 chgparam cpp
[[lesson_11_chgparam_cpp]] last edit on Aug 18, 2005 6:52 AM by rescued_by_c

[user02@FC4 Lesson11]$ cat -n chgparam.cpp
   1  #include <iostream>
   2  using namespace std;
   3
   4  void change_values(int *a, int *b)

   5  {
   6     *a = 1001;
   7     *b = 1001;
   8
   9     cout << "The values within display_values are " << *a << " and " << *b << endl;
  10  }
  11
  12  int main()
  13  {
  14     int big = 2002, small = 0;
  15
  16     cout << "Values before function " << big << " and " << small << endl;
  17
  18     change_values(&big, &small);
  19
  20     cout << "Values after function " << big << " and " << small << endl;
  21
  22     return 0;
  23  }
[user02@FC4 Lesson11]$ g++ -o chgparam chgparam.cpp
[user02@FC4 Lesson11]$ ./chgparam
Values before function 2002 and 0
The values within display_values are 1001 and 1001
Values after function 1001 and 1001
[user02@FC4 Lesson11]$