Last active
March 24, 2017 09:41
-
-
Save chrisbarrett/5794687 to your computer and use it in GitHub Desktop.
C Array object usage example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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