Skip to content

Instantly share code, notes, and snippets.

@tekknolagi
Created October 17, 2011 19:53
Show Gist options
  • Save tekknolagi/1293602 to your computer and use it in GitHub Desktop.
Save tekknolagi/1293602 to your computer and use it in GitHub Desktop.
array diff types
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define int(x) *((int *) x)
int main() {
void *a[2];
char *b = "hello";
a[1] = calloc(strlen(b), sizeof(char));
a[1] = strncpy(a[1], b, strlen(b));
a[0] = calloc(1, sizeof(int));
int(a[0]) = strlen(a[1]);
printf("%d\n", int(a[0]));
printf("%s\n", a[1]);
free(a[1]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment