doing extra credit for ch23 ex22

This commit is contained in:
Dan Buch 2011-11-04 00:01:16 -04:00
parent 316ce7f8be
commit 601f722221
2 changed files with 29 additions and 1 deletions

View File

@ -1,4 +1,4 @@
all: ex22_main
all: ex22_main ex22_ec1
ex22_main: ex22_main.o ex22.o

28
ex22_ec1.c Normal file
View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include "dbg.h"
int pass_by_value(int n)
{
n = n + 2;
return n;
}
int pass_by_reference(int *n)
{
*n = *n + 8;
return *n;
}
int main(int argc, char *argv[])
{
int n = 2;
log_info("BEGIN: n = %d", n);
log_info("By value example: %d", pass_by_value(n));
log_info("n = %d", n);
log_info("By reference example: %d", pass_by_reference(&n));
log_info("n = %d", n);
return 0;
}