box-o-sand/oldstuff/lcthw-remnants/ex22_ec1.c

29 lines
434 B
C
Raw Normal View History

2011-11-04 04:01:16 +00:00
#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;
2011-11-04 12:24:07 +00:00
log_info("n = %d", n);
2011-11-04 04:01:16 +00:00
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;
}