User Profile
Collapse
-
Excellent, this worked! Thanks to ravenspoint, RedSon, and mac111! -
Dynamic Array of Structs Problem
Greetings all, I had another post on here about a Dynamic array of ints problem, and with your help, I managed to solve that problem. Now, I've another issue. I need to dyanically allocate an array of structs.
The struct is defined as:
So, for work, they want me to sort through the songs, but due to memory constraints...Code:struct song{ char name[50]; char title[50]; }; -
-
Ok, that's not a problem. But, say I do malloc it like this:
struct queue {
int front;
int elements;
int asize;
int * qlist;
};
...
struct queue * resize(int size){
struct queue * q;...
q->front = 0;
q->elements = 0;
q->asize = size;
q->qlist = (int *)malloc(sizeof (int) * size);Leave a comment:
-
Dynamic array of ints problem
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...
No activity results to display
Show More
Leave a comment: