just a sample of what can be done

Dependencies:   mbed

PRN電卓プログラム

「プログラミング言語C (K&R本)」に出てくる例を元にした,RPN計算機です.

hp写真はイメージです

このプログラムは..

getch.cpp

Committer:
okano
Date:
2015-06-27
Revision:
5:3b9daee5f734
Parent:
4:b4c8aee2ecad

File content as of revision 5:3b9daee5f734:

#include    "mbed.h"
#include    "calc.h"
#include    <ctype.h>

#define     BUFSIZE 100

char    buf[ BUFSIZE ];
int     bufp    = 0;

int getch( void )
{
#if 1
    int c;
    c   = (bufp > 0) ? buf[ --bufp ] : getchar();
    if ( isprint( c ) && c != ' ' )
        printf( "[%c]\r\n", c );
    return c;
#else
    return (bufp > 0) ? buf[ --bufp ] : getchar();
#endif
}


void ungetch( int c )
{
    if ( bufp >= BUFSIZE )
        printf( "ungetch: too many characters\n" );
    else
        buf[ bufp++ ]   = c;
}