Skip to content

Instantly share code, notes, and snippets.

@jeremyBanks
Created September 15, 2008 22:25
Show Gist options
  • Save jeremyBanks/10957 to your computer and use it in GitHub Desktop.
Save jeremyBanks/10957 to your computer and use it in GitHub Desktop.
[2010-01] me being thrilled upon discovering alloca
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit
// http://stackoverflow.com/questions/31937/what-is-your-favourite-non-standard-c-library-function#32064
#include <stdio.h>
#include <alloca.h>
int main(int argc, char* argv[]) {
char* myString = alloca(sizeof(char) * 5);
myString[0] = 'H';
myString[1] = 'e';
myString[2] = 'y';
myString[3] = '.';
myString[4] = 0;
printf("%s", myString);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment