We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c182d04 commit 23e715eCopy full SHA for 23e715e
archive/c/cyclone/baklava.cyc
@@ -0,0 +1,28 @@
1
+#include <stdio.h>
2
+#include <string.h>
3
+
4
+int main() {
5
+ char line[22];
6
7
+ // Tell compiler that pointer math is going to be done, and the result
8
+ // may not be null terminated
9
+ char *@fat @nozeroterm line_ptr = line;
10
11
+ for (int n = -10; n <= 10; n++) {
12
+ int num_spaces = (n >= 0) ? n : -n;
13
+ int num_stars = 21 - 2 * num_spaces;
14
15
+ // Write num_spaces " " to line
16
+ memset(line_ptr, ' ', num_spaces);
17
18
+ // Append num_stars "*" to line
19
+ memset(&line_ptr[num_spaces], '*', num_stars);
20
21
+ // Null terminate line
22
+ line_ptr[num_spaces + num_stars] = '\0';
23
24
+ printf("%s\n", line);
25
+ }
26
27
+ return 0;
28
+}
0 commit comments