Skip to content

Commit 25e77a8

Browse files
committed
updated Chapter 10
1 parent cc0d34b commit 25e77a8

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

21stCenturyC/Chapter10.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ f(double[]) {20.38, a_value, 9.8}); // OK
44

55
- Automatically allocated, neither malloc nor free needed.
66

7-
#include <math.h> // NAN
8-
#include <stdio.h>
9-
10-
double sum(double in[]) {
11-
double out = 0;
12-
for (int i = 0; !isnan(in[i]); ++i) out += in[i];
13-
return out;
14-
}
7+
-#include <math.h> // NAN
8+
-#include <stdio.h>
9+
-
10+
-double sum(double in[]) {
11+
- double out = 0;
12+
- for (int i = 0; !isnan(in[i]); ++i) out += in[i];
13+
- return out;
14+
-}
1515

1616
int main() {
1717

@@ -24,3 +24,17 @@ sizeof(list) == sizeof(double*)
2424

2525

2626
##Variadic Macros
27+
28+
-#define forloop(i, loopmax, ...) for (int i=0; i < loopmax; ++i) \
29+
{__VA_ARGS__}
30+
31+
-int main() {
32+
33+
int sum = 0;
34+
forloop(i, 10,
35+
sum += i;
36+
printf("sum to %i:\n", i, sum);
37+
)
38+
}
39+
40+

0 commit comments

Comments
 (0)