Skip to content

Instantly share code, notes, and snippets.

@computermouth
Created March 31, 2017 07:35
Show Gist options
  • Save computermouth/791c86235b28cfa22e7fbd23f398a397 to your computer and use it in GitHub Desktop.
Save computermouth/791c86235b28cfa22e7fbd23f398a397 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
typedef struct{
//doesn't compile without parens
unsigned char (*c)[3];
}a_t;
int main(){
a_t a;
//single dimensional malloc since i always know the length of a.c
a.c = malloc(sizeof(char[3]) * 10);
a.c[0][0] = 23;
a.c[5][2] = 11;
printf("a.c[0][0] = %d\na.c[5][2] = %d\n", a.c[0][0], a.c[5][2]);
free(a.c);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment