Created
March 31, 2017 07:35
-
-
Save computermouth/791c86235b28cfa22e7fbd23f398a397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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