home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C by Discovery (4th Edition)
/
C_By_Discovery_4th_Edition.tar
/
C_By_Discovery_4th_Edition
/
_DISK_
/
ch8
/
stackex.c
< prev
next >
Wrap
C/C++ Source or Header
|
2005-06-16
|
1KB
|
37 lines
/* stackex.c
*
* Synopsis - A driver program to test the stack utilities.
* This program accepts a line of input from
* standard input and displays the first eight
* characters in reverse order to standard output.
* Objective - To demonstrate and test the stack utilities.
*/
/* Include Files */
#include <stdio.h>
#include "stack.h" /* Note 1 */
/* Constant Definitions */
#define BUF_SIZE 80
int main( void )
{
char inbuff[BUF_SIZE];
int index;
STACK st; /* Note 2 */
printf( "Enter a line of characters : " );
fgets( inbuff, BUF_SIZE, stdin );
init_stack( &st ); /* Note 3 */
for ( index = 0; inbuff[index] != '\0'; index++ ) {
push( inbuff[index], &st );
}
while ( !is_empty( st ) ) {
putchar( pop( &st ) );
}
putchar( '\n' );
return 0;
}