Here is my code: The first, is the structure i use:
Code:
typedef struct _SFont
{
ID3DXFont *Fontobj;
char *name;
LOGFONT FontParams;
}SFont;
Then, i make a variable of that type, which i want it as an array later. I also have a counter.
Code:
unsigned int counter;
SFont *eFont;
char test[30];
Then, I have a function that increases the counter by one:
I change the array size like that and attach a name to the current:
Code:
rFont = (SFont*)realloc(rFont, sizeof(SFont)*counter);
sprintf (test, "ArrayItem %i", counter);
rFont[counter].name = test;
somewhy, this code doesnt work, but crashes. Is there another way i could use dynamic arrays?