home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ User's Journal & Wi…eveloper's Journal Tools
/
C-C__Users_Journal_and_Windows_Developers_Journal_Tools_1997.iso
/
windbase
/
windbase.exe
/
MEMSLC.3
/
DQUEUE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-11
|
4KB
|
102 lines
/*****************************************************************************\
** **
** WW WW IIIIIIII NNN NN DDDDDDD BBBBBBB AA SSSSSS EEEEEEEE **
** WW W WW II NNNN NN DD DD BB BB AA AA SS EE **
** WW W WW II NN NN NN DD DD BBBBBBB AAAAAAAA SSSSSS EEEEEE **
** WW W WW II NN NNNN DD DD BB BB AA AA SS EE **
** WWWWW IIIIIIII NN NNN DDDDDDD BBBBBBB AA AA SSSSSS EEEEEEEE **
** **
** SSSSSS OOOOOO FFFFFFFF TTTTTTTT WW WW AA RRRRRRR EEEEEEEE **
** SS OO OO FF TT WW W WW AA AA RR RR EE **
** SSSSS OO OO FFFFF TT WW W WW AAAAAAAA RRRRRRR EEEEEE **
** SS OO OO FF TT WW W WW AA AA RR RR EE **
** SSSSSS OOOOOO FF TT WWWWW AA AA RR RR EEEEEEEE **
** **
*********** NOTICE ************************************************************
** This file contains valuable trade secrets and proprietary **
** assets of Windbase Software Inc. Embodying substantial **
** creative efforts and confidential information. Unauthorized **
** use, copying, decompiling, translating, disclosure or **
** transfer, of any kind, is strictly prohibited. **
** **
** COPYRIGHT (C) 1992, 1993, 1994. Windbase Software Inc. **
** ALL RIGHTS RESERVED. **
\*****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include "../memsl.h"
#if defined(WBTRC_LEVEL1) || defined(WBTRC_LEVEL2)
#ifdef WBSTDC
int main(int argc, char **argv)
#else
int main(argc, argv)
int argc;
char **argv;
#endif
#else
#ifdef WBSTDC
int main(void)
#else
int main()
#endif
#endif
{
FILE *file;
WBDQUEUE *dqueue;
char str[21], item[21], *strptr;
WBTrcMainEntry();
#if 1 /* Dequeue using an array and having the dqueue copy the items */
printf("Dequeue using an array:\n");
if ((dqueue = WBDQueueOpen(NULL,21,50,1)) != NULL)
{
if ((file = fopen("data.dat","r")) != NULL)
{
while (fgets(str,20,file))
{
if (WBDQueuePushL(dqueue,str) == 0)
{
printf("Popping: %s",WBDQueuePopL(dqueue,item));
WBDQueuePushR(dqueue,str);
}
}
while ((strptr = WBDQueuePopR(dqueue,item)) != NULL)
printf("%s %s",strptr, item);
fclose(file);
}
WBDQueueClose(dqueue);
}
#else /* Dequeue using a linked list */
printf("Dequeue using a linked list:\n");
if ((dqueue = WBDQueueOpen(NULL,0,0,0)) != NULL)
{
if ((file = fopen("data.dat","r")) != NULL)
{
while (fgets(str,20,file))
{
if ((strptr = malloc(strlen(str)+1)) != NULL)
{
strcpy(strptr,str);
WBDQueuePushL(dqueue,strptr);
}
}
fclose(file);
while ((strptr = WBDQueuePopL(dqueue,NULL)) != NULL)
{
printf("%s",strptr);
free(strptr);
}
}
WBDQueueClose(dqueue);
}
#endif
WBTrcReturn(0,0,("0"));
}