![]() |
| | #1 |
| Registered User Join Date: Dec 2001
Posts: 25
| half ADT (nested struct) problem... I ve got problem in implementing ADT in my program, below I posted my PQ.c, PQ.h -> which is the ADT (not full ADT) you'll see why in my code...and office.c+ office. which is the program using the functions implemented in PQ this is the code (not full code, but will gives you the idea of my problem): PQ.h Code: typedef struct workers PQItem;
//typedef WRecord PQItem;
struct pqueue
{
int size;
PQItem *item;
};
typedef struct pqueue PQ;
PQ *initPQ( void );
void swapArray( PQItem *arr1, PQItem *arr2 );
Code: #include <stdio.h>
#include <stdlib.h>
#include "PQ.h"
PQ *initPQ( void )
{
PQ *pq;
pq = malloc ( sizeof(PQ) );
if( pq == NULL )
{
fprintf( stderr, "ERROR: Memory allocation for priority queue failed;"
"program terminated.\n" );
exit( EXIT_FAILURE );
}
return pq;
}
void swapArray( PQItem *arr1, PQItem *arr2 )
{
PQItem temp;
temp = *arr1;
*arr1 = *arr2;
*arr2 = temp;
return;
}
Code: #include "PQ.h"
#define NAMESIZE 100
#define BASE 100
/* Structure Template */
typedef int Time;
struct workers
{
char *name;
Time starttime;
Time stoptime;
};
typedef struct workers WRecord;
//typedef struct workers PQItem;
/* Functions Prototype */
void usage( char *progname );
FILE *open_file( char *progname, char *fname, const char *mode );
char *alloc_string_memory( int len );
char *get_name( FILE *fp );
WRecord *read_worker( FILE *fp, int workers_total );
Time add_time( Time time1, Time time2);
Code: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "office.h"
int main (argc....)
{
/* main program here, not related with problem */
}
/*functions here (from function prototype declared in office.h, which is not related as well IMO */
Code: typedef struct workers PQItem; but so far what I ve get is these error: - redefinition error -or no semicoolon at the end of the struct -or pointer redeferencing into INCOMPLETE type (this is in swapArray functions in PQ.c, where it doesnt recognize PQItem, and I believe this is the problem, HOW to make PQItem recognized??) i hope someone can help me or gimme any suggestion, I dont need full ADT...just semi ADT thanks Ferdinand |
| CyC|OpS is offline | |
| | #2 |
| Registered User Join Date: Dec 2001
Posts: 25
| anyone? |
| CyC|OpS is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| very weird problem (pointers I think) | hannibar | C Programming | 2 | 10-11-2005 06:45 AM |
| Struct Problem | Mr.Modem | C Programming | 5 | 08-13-2005 03:19 PM |
| Problem constructing a class with a nested struc | pliang | C++ Programming | 3 | 04-14-2005 07:43 PM |
| Passing pointers between functions | heygirls_uk | C Programming | 5 | 01-09-2004 06:58 PM |
| Bi-Directional Linked Lists | Thantos | C Programming | 6 | 12-11-2003 10:24 AM |