Hello........ have some problems with implementing a queue.
Basically what im trying to do is write a function that writes stores a variable number of elements from a struct array to a linked-list. here are parts of the code...
when i try to compile it, i get:
C:\Documents and Settings\Ramon Lozano\My Documents\Visual Studio 2005\Projects\Project 0\fig11_15.c(115) : error C2039: 'nexptr' : is not a member of 'data_1'
Code:
struct data {
char date[12];
double price;
};
struct data_1 {
double price_1;
struct data_1 *nextptr;
};
typedef struct data Data;
typedef struct data_1 Data_1;
typedef Data_1 *Data_1ptr;
void queue( Data data_2[], int size, Data_1ptr *ptr1, Data_1ptr *ptr2, int a, int b);
int main()
{
int i = 0, test, start, end;
double average, max_price;
Data price_data[252];
Data_1ptr startptr = NULL;
Data_1ptr endptr = NULL;
Queue( price_data, 252, startptr, endptr, start, end);
return 0;
}
void Queue( Data data_2[], int size, Data_1ptr *ptr1, Data_1ptr *ptr2, int a, int b)
{
int ctr =0;
Data_1ptr newptr;
newptr = malloc( sizeof( Data_1 ));
for ( ctr = a; ctr <= b; ctr++) {
if ( newptr != NULL ) {
newptr->price_1 = data_2[ctr].price;
newptr->nextptr = NULL;
if ( *ptr1 == NULL ) { *ptr1 = newptr; }
else { (*ptr2)->nexptr = newptr; }
*ptr2 = newptr;
}
else {
printf(" No memory available.\n");
}
}
}