-
Notifications
You must be signed in to change notification settings - Fork 0
/
foo.c
53 lines (41 loc) · 908 Bytes
/
foo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int foo() {
printf("called foo()\n");
return 2;
}
int printNl(char *literal) {
printf("%s\n", literal);
}
int print(char *literal) {
printf("%s ", literal);
}
int printNum(int num) {
printf("%d ", num);
}
int bar(int x, int y) {
int result = x + y;
printf("%d + %d = %d\n", x, y, result);
return result;
}
int add6(int a, int b, int c, int d, int e, int f) {
return a + b + c + d + e + f;
}
void alloc4(int **p, int a, int b, int c, int d) {
int *tmp = malloc(4 * 4);
tmp[0] = a;
tmp[1] = b;
tmp[2] = c;
tmp[3] = d;
*p = tmp;
return;
}
int assert(int expected, int actual, char *code) {
if (expected == actual) {
printf("%s => %d\n", code, actual);
} else {
printf("%s => %d expected but got %d\n", code, expected, actual);
exit(1);
}
}