Skip to content

Instantly share code, notes, and snippets.

@jrfondren
Created May 13, 2019 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrfondren/9cb9742c2ed22b52b278837739780106 to your computer and use it in GitHub Desktop.
Save jrfondren/9cb9742c2ed22b52b278837739780106 to your computer and use it in GitHub Desktop.
flexible array members in C
#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