>>44を見てひらめいた、
c = getchar(); /* 次の入力を見て */
ungetc(c, stdin); /* 戻しておいて */
if (isdigit(c) && scanf("%d", &n)) {ほにゃほにゃ};
/* スキャン */
ちゅーのは合法なんでしょうか?