Thread: Help with Queue

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    12

    Help with Queue

    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");
    			 }
    		}
    	
    }

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Code:
    >			else { (*ptr2)->nexptr = newptr; }
    Check your spelling of next.

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    12
    ha ha.. thnx........... , Ive been stuck on that problem for ab hour..im one D**b F**k

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 08:17 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 03:55 AM
  3. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 09:09 PM
  4. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 11:39 AM
  5. queue help
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 10-29-2001, 09:38 AM