Skip to content

Instantly share code, notes, and snippets.

@rexim
Created January 25, 2020 17:25
Show Gist options
  • Select an option

  • Save rexim/d2fd57d6f886f545cf5fa2ec9082612c to your computer and use it in GitHub Desktop.

Select an option

Save rexim/d2fd57d6f886f545cf5fa2ec9082612c to your computer and use it in GitHub Desktop.
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int x;
int y;
} Point;
int main(int argc, char *argv[])
{
if (argc < 2) {
assert(argc >= 1);
fprintf(stderr, "Usage: %s <N>\n", argv[0]);
exit(1);
}
int n = atoi(argv[1]);
Point *points = malloc(sizeof(Point) * n);
for (int i = 0; i < n; ++i) {
points[i].x = i;
points[i].y = i;
}
free(points);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment