blob: e7640e6758629a3fd8153e825a83b7a61c65586f (
plain) (
tree)
|
|
#include <stdio.h>
#include <ctype.h>
#include "op.h"
char getop(char *op, size_t len)
{
size_t i;
*op = '\0'; // if scanf fails
do {
scanf("%c", op);
} while (isblank(*op));
if (!isdigit(*op))
return *op;
i = 1;
do {
scanf("%c", op + i);
} while (isdigit(op[i]) && ++i < len);
if (op[i] == '.') {
i++;
do {
scanf("%c", op + i);
} while (isdigit(op[i]) && ++i < len);
}
ungetc(op[i], stdin);
op[i] = '\0';
return NUM;
}
|