lesson 11 chgparam c
[[lesson_11_chgparam_c]] last edit on
Aug 18, 2005
6:54 AM
by rescued_by_c
[user02@FC4 Lesson11]$ cat -n chgparam.c
[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]$
1 #include <stdio.h>
2
3 void change_values(int *a, int *b)
4 {
5 *a = 1001;
6 *b = 1001;
7
8 printf("The values within display_values are %d and %d\n", *a, *b);
9 }
10
11 int main(void)
12 {
13 int big = 2002, small = 0;
14
15 printf("Values before function %d and %d\n", big, small);
16
17 change_values(&big, &small);
18
19 printf("Values after function %d and %d\n", big, small);
20
21 return 0;
22 }
[user02@FC4 Lesson11]$ gcc -o chgparam chgparam.c[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]$