g_client.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 + -
显示快捷键?