Code:
RECORD_DATA *stock_rec,*s;
// This is not neccisary
// stock_rec=malloc(sizeof(RECORD_DATA));
// Okay, now s is an array of RECORD_DATA
s=malloc(record_count*sizeof(RECORD_DATA));
// stock_rec is the variable we use to step through the array
stock_rec=s;
while(something)
{
// This is the problem, you are just changing the value of stock_rec. Instead you need to change the value of what it is pointing at.
//stock_rec= (a function returns a pointer to data struct of type
RECORD_DATA )
// There are two ways to do this...
changeRec (stock_rec); // example below
// orr...
*stock_rec = (a function that returns a RECORD_DATA [not a pointer])
stock_rec++;
}
The first way, passing the pointer to the record in a function, is considered the better way, because you don't want a function to return structures which take a lot of memory.
Code:
void changeRec (RECORD_DATA * p)
{
p -> info = 0;
p -> artist = 'M';
p -> foo = bar;
// etc...
}