Skip to content

Instantly share code, notes, and snippets.

@whyrusleeping
Forked from travisperson/for shortcut
Created October 6, 2012 00:55
Show Gist options
  • Save whyrusleeping/3843297 to your computer and use it in GitHub Desktop.
Save whyrusleeping/3843297 to your computer and use it in GitHub Desktop.
My favorite Pre-processor hackery
#include <stdio.h>
#define to ; i <=
#define DO(range) for(int i = range; i++)
int main()
{
int arr[10];
DO(0 to 9)
arr[i] = 2 * i;
DO(0 to 9)
printf("%d\n", arr[i]);
return 0;
}
@whyrusleeping
Copy link
Author

I like it this way better:
https://gist.github.com/3843297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment