Skip to content

Instantly share code, notes, and snippets.

@chrisbarrett
Last active March 24, 2017 09:41
Show Gist options
  • Save chrisbarrett/5794687 to your computer and use it in GitHub Desktop.
Save chrisbarrett/5794687 to your computer and use it in GitHub Desktop.
C Array object usage example
#include <stdio.h>
#include "array_obj.h"
int main()
{
// Allocate an array of 5 ints.
Array_new(xs, int, 5);
// Initialize elements using their indices.
xs.each_i(^(int x, int i) { xs.set(i, i); });
// Print elements.
xs.each(^(int x){ printf("%i\n", x); });
xs.free();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment