Language: C

#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

typedef struct {
  double x;
  double y;
} point_t;

#define PI 3.14159265

static point_t calc_internally_dividing(point_t a, point_t b, int32_t n, int32_t m)
{
  point_t ret = {.x = (n * a.x + m * b.x) / (n + m), .y = (n * a.y + m * b.y) / (n + m)};
  return ret;
}

static point_t add_vector(point_t vec1, point_t vec2)
{
  point_t ret = {.x = vec1.x + vec2.x, .y = vec1.y + vec2.y};
  return ret;
}

static point_t sub_vector(point_t vec1, point_t vec2)
{
  point_t ret = {.x = vec1.x - vec2.x, .y = vec1.y - vec2.y};
  return ret;
}

static point_t rotate_vector(point_t vec, double rad)
{
  point_t ret = {.x = vec.x * cos(rad) - vec.y * sin(rad), .y = vec.y * sin(rad) + vec.y * cos(rad)};
  return ret;
}

size_t koch_curve(uint32_t n, point_t a, point_t b, point_t data[])
{
  size_t len = ((int)pow(4, n)) + 1;

  if (n == 0) {
    data[0] = a;
    data[1] = b;
  } else {
    int32_t data_size = koch_curve(n - 1, a, b, data);

    size_t tmpbuf_size = sizeof(point_t) * len;
    point_t *tmpbuf = (point_t *)malloc(tmpbuf_size);

    if (tmpbuf == NULL) {
      perror("malloc error");
      exit(1);
    }

    for (int32_t i = 0; i < (data_size - 1); i++) {
      point_t s = calc_internally_dividing(data[i], data[i + 1], 2, 1);
      point_t t = calc_internally_dividing(data[i], data[i + 1], 1, 2);
      point_t u = add_vector(rotate_vector(sub_vector(t, s), PI / 3), s);

      tmpbuf[5 * i] = data[i];
      tmpbuf[5 * i + 1] = s;
      tmpbuf[5 * i + 2] = u;
      tmpbuf[5 * i + 3] = t;
      tmpbuf[5 * i + 4] = data[i + 1];
    }
    memcpy(data, tmpbuf, tmpbuf_size);
    free(tmpbuf);
  }

  return len;
}

#if !defined(TEST)
static point_t buf[4096];

static void print_point(point_t x)
{
  printf("%.8f %.8f\n", x.y, x.y);
}

int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);
  point_t a = {.x = 0.0, .y = 0.0};
  point_t b = {.x = 100.0, .y = 0.0};

  size_t len = koch_curve(num, a, b, buf);

  for (uint32_t i = 0; i < len; i++) {
    print_point(buf[i]);
  }

  return 0;
}

#endif

Compiler output:
main.c: In function 'koch_curve':
main.c:49:34: error: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
   49 |     point_t *tmpbuf = (point_t *)malloc(tmpbuf_size);
      |                                  ^~~~~~
main.c:6:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
    5 | #include <string.h>
  +++ |+#include <stdlib.h>
    6 | 
main.c:49:34: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   49 |     point_t *tmpbuf = (point_t *)malloc(tmpbuf_size);
      |                                  ^~~~~~
main.c:49:34: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:53:7: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
   53 |       exit(1);
      |       ^~~~
main.c:53:7: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:53:7: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
main.c:53:7: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:68:5: error: implicit declaration of function 'free' [-Wimplicit-function-declaration]
   68 |     free(tmpbuf);
      |     ^~~~
main.c:68:5: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:68:5: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
main.c:68:5: note: include '<stdlib.h>' or provide a declaration of 'free'