Skip to content

Instantly share code, notes, and snippets.

@whyrusleeping
Forked from travisperson/for shortcut
Created October 6, 2012 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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