C - array aloccation : I have following code and i need to allocate memory for char data[]. I tryed many things, but it still doesnt work. Can someone help me ? I know my malloc wont allocate anything for data, but how to repair this.

//img->data = malloc(sizeof(char)*(img->xsize * img->ysize * 3)); need data allocate like this

```
struct ppm {
    unsigned xsize;
    unsigned ysize;
    char data[]; 
};
struct ppm *img = malloc(sizeof(struct ppm));
if (!img) 
     fprintf(stderr, "Chyba alokace pameti.\n");
     exit(1);
}
if (fscanf(fp, "%x %x", &img->xsize, &img->ysize) != 2) {
     fprintf(stderr, "Spatna velikost obrazku '%s'\n", filename);
     exit(1);
}
if (fread(img->data, 3 * img->xsize, img->ysize, fp)) 
     fprintf(stderr, "Nepodarilo se nacist pixely z '%s'\n", filename);
     exit(1);
}
```