I want to create a 'n' size of array structure but I don't know how to do it. I always create static like this
typedef struct
{
int id;
char name[25];
char dob[11];
}info;
info student[5];
here i want it info student[n] but it doesn't work because it takes only integer.
It seems you mean the following code
where n is some variable of an integer type.
This declaration of an array declares a variable length array. Variable length arrays may have only automatic storage duration . So you may declare such an array in a function as for example
You may not declare a variable length array in a file scope.
Pay attention to that the value of the variable
nshall be a positive number. Another peculiarity is that you may not initialize elements of a variable length array in its declaration.If your compiler does not support variable length arrays then you need to allocate an array of structures dynamically like for example