Hey can anyone help me here please...
This is a program in c called circbuf.1.c, and i have to draw a diagram for the following data structure fragment which is executed as follows:
for (k = 0; k < = 10; k++)
pushout(buf, '$', &c);
remchars(buf, 6);
The details of the functions mentioned above are as follows:
cheers, atif
/*******************
* circbuf.1.h *
*******************/
/************************************************** **************
* *
* Prototypes for functions operating on buffer. *
* *
* Last revised: 03/4/97. Copyright: M. Cook *
* *
* init_bufr(n): *
* allocates buffer, size n; returns pointer to buffer. *
* *
* pushout(buffer,a,b): *
* adds a to buffer; returns true if a overwrites oldest *
* char which is copied to *b; returns false otherwise *
* *
* remchars(buffer,n): *
* removes the n oldest chars from buffer *
* *
* matchkey(buffer,key): *
* returns true if the string key matches the contents of *
* the buffer, STARTING FROM THE OLDEST CHARACTER in buffer*
* *
* pick_char(buffer,k,b): *
* copies kth oldest character in buffer to *b, returning *
* true if successful or false if there was no such char *
* *
* dump_bufr(buffer): *
* for debugging: writes to stderr the current contents of *
* buffer and its idea of how many chars; the next vacant *
* spot and/or oldest character is marked by >>> *
* *
* clr_bufr(buffer): *
* empties, but doesn't destroy buffer *
* *
* delete_bufr(bufptr): *
* destroys buffer (== *bufptr) sets *bufptr to null *
* *
************************************************** **************/
#ifndef BUFR
#define BUFR void *
#endif
BUFR init_bufr(int);
int pushout( BUFR , int, int * );
int remchars( BUFR , int );
int matchkey( BUFR , char * );
int pick_char( BUFR , int, char * );
void dump_bufr(BUFR );
void clr_bufr(BUFR );
void delete_bufr(BUFR *);