Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
getop.cpp@2:0e96f4495b43, 2015-06-26 (annotated)
- Committer:
- okano
- Date:
- Fri Jun 26 10:16:24 2015 +0000
- Revision:
- 2:0e96f4495b43
- Child:
- 3:4ef74510cc5b
divided to multiple modules
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| okano | 2:0e96f4495b43 | 1 | #include "mbed.h" |
| okano | 2:0e96f4495b43 | 2 | #include "calc.h" |
| okano | 2:0e96f4495b43 | 3 | |
| okano | 2:0e96f4495b43 | 4 | #include <ctype.h> |
| okano | 2:0e96f4495b43 | 5 | |
| okano | 2:0e96f4495b43 | 6 | int getop( char s[] ) |
| okano | 2:0e96f4495b43 | 7 | { |
| okano | 2:0e96f4495b43 | 8 | int i, c; |
| okano | 2:0e96f4495b43 | 9 | |
| okano | 2:0e96f4495b43 | 10 | while ( (s[ 0 ] = c = getch()) == ' ' || c == '\t' ) |
| okano | 2:0e96f4495b43 | 11 | ; |
| okano | 2:0e96f4495b43 | 12 | |
| okano | 2:0e96f4495b43 | 13 | s[ 1 ] = '\0'; |
| okano | 2:0e96f4495b43 | 14 | |
| okano | 2:0e96f4495b43 | 15 | if ( !isdigit( c ) && c != '.' ) |
| okano | 2:0e96f4495b43 | 16 | return c; |
| okano | 2:0e96f4495b43 | 17 | |
| okano | 2:0e96f4495b43 | 18 | i = 0; |
| okano | 2:0e96f4495b43 | 19 | |
| okano | 2:0e96f4495b43 | 20 | if ( isdigit( c ) ) |
| okano | 2:0e96f4495b43 | 21 | while ( isdigit( s[ ++i ] = c = getch() ) ) |
| okano | 2:0e96f4495b43 | 22 | ; |
| okano | 2:0e96f4495b43 | 23 | |
| okano | 2:0e96f4495b43 | 24 | if ( c == '.' ) |
| okano | 2:0e96f4495b43 | 25 | while ( isdigit( s[ ++i ] = c = getch() ) ) |
| okano | 2:0e96f4495b43 | 26 | ; |
| okano | 2:0e96f4495b43 | 27 | |
| okano | 2:0e96f4495b43 | 28 | s[ i ] = '\0'; |
| okano | 2:0e96f4495b43 | 29 | |
| okano | 2:0e96f4495b43 | 30 | |
| okano | 2:0e96f4495b43 | 31 | if ( c != EOF ) |
| okano | 2:0e96f4495b43 | 32 | ungetch( c ); |
| okano | 2:0e96f4495b43 | 33 | |
| okano | 2:0e96f4495b43 | 34 | return NUMBER; |
| okano | 2:0e96f4495b43 | 35 | } |