doing extra credit for ch23 ex22
This commit is contained in:
parent
316ce7f8be
commit
601f722221
2
ex22.mk
2
ex22.mk
@ -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
28
ex22_ec1.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user