g_client.c

来自「c和指针 学习c语言必须阅读的书籍之一 提高对C语言的掌握理解能力」· C语言 代码 · 共 45 行

C
45
字号
/*
** A client that uses the generic stack module to create two stacks
** holding different types of data.
*/
#include <stdlib.h>
#include <stdio.h>
#include "g_stack.h"

/*
**	Create two stacks, one of integers and one of floats.
*/
GENERIC_STACK( int, _int, 10 )
GENERIC_STACK( float, _float, 5 )

int
main()
{
	/*
	** Push several values on each stack.
	*/
	push_int( 5 );
	push_int( 22 );
	push_int( 15 );
	push_float( 25.3 );
	push_float( -40.5 );

	/*
	** Empty the integer stack and print the values.
	*/
	while( !is_empty_int() ){
		printf( "Popping %d\n", top_int() );
		pop_int();
	}

	/*
	** Empty the float stack and print the values.
	*/
	while( !is_empty_float() ){
		printf( "Popping %f\n", top_float() );
		pop_float();
	}

	return EXIT_SUCCESS;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?