diff options
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 35 |
1 files changed, 20 insertions, 15 deletions
@@ -2,22 +2,27 @@ #include <string.h> #include <stdlib.h> +typedef struct { + int age; + int happiness; // 0 sad, 100 happy +} Person; + +void slide(Person *person) +{ + person->happiness += 10; +} + +// pass by value +// pass by reference int main(int argc, char *argv[]) { - // AND && - // OR || - // - int age = 30; + Person *mo = malloc(sizeof(Person)); + mo->age = 36; + mo->happiness = 70; - if (/* */) - { - printf("Fly to Hawaii\n"); - } - else - { - printf("Camp in the back yard\n"); - } -} + printf("Before: age(%d), happiness(%d)\n", mo->age, mo->happiness); + + slide(mo); -// 1. compile: c -> machine -// 2. run: machine -> os + printf("After: age(%d), happiness(%d)\n", mo->age, mo->happiness); +} |
