lundi 29 juin 2015

Changing the size of struct after declared


I have a code contains this structure

struct mystruct{
int a;
int array[1];
};

Directly,after running the code I mean I will not declare any variable of that structure,the user will enter a number, for example 6 What I want is how I can change the size of that structure Like I declared on this form

struct mystruct{
int a;
int array[6];
};

Then I use normally, like this:

struct mystruct var;
//I do not want to add any code here,to appropriate new form
for(int i=0;i<6;i++)
var.array[i]=0;


Aucun commentaire:

Enregistrer un commentaire