Created
May 13, 2019 13:51
-
-
Save jrfondren/9cb9742c2ed22b52b278837739780106 to your computer and use it in GitHub Desktop.
flexible array members in C
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 { | |
char len; | |
char cap; | |
char data[]; | |
} MySeq; | |
void dump (MySeq *seq) { | |
printf("seq.data: %s\n", seq->data); | |
} | |
int main (void) { | |
char *s = "\06\00hello"; | |
dump((MySeq*) s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment