Greetings all, I'm working on a program that contains a struct:
struct queue {
int front; //the front of the queue
int elements; //the number of elements in the queue
int asize; //the size of the array
int qlist[]; //an array that will be dynamically sized
};
My objective is to read from a file, the length of the queue. Now, I've tried to use malloc, realloc and sorts of things to resize the array qlist[]. All my attempts have failed. My question: how can I resize qlist[] to store a number of ints specified at runtime?
I'd like to use a pointer to the struct, instead of the struct itself, if possible. Example: struct queue * q, instead of struct queue q;
Thanks in Advance.
struct queue {
int front; //the front of the queue
int elements; //the number of elements in the queue
int asize; //the size of the array
int qlist[]; //an array that will be dynamically sized
};
My objective is to read from a file, the length of the queue. Now, I've tried to use malloc, realloc and sorts of things to resize the array qlist[]. All my attempts have failed. My question: how can I resize qlist[] to store a number of ints specified at runtime?
I'd like to use a pointer to the struct, instead of the struct itself, if possible. Example: struct queue * q, instead of struct queue q;
Thanks in Advance.
Comment