1 #ifndef lint 2 static char rcsid[] = 3 "$Id: is_num_str.c,v 1.1 1997/02/28 14:02:50 tommy Exp $"; 4 #endif 5 6 #include <stdio.h> 7 #include <stdlib.h> 8 #include <ctype.h> 9 #include "play.h" 10 check_numarg(char * arg,char opt)11int check_numarg(char *arg, char opt) 12 { 13 if (!is_num_str(arg)) { 14 fprintf(stderr, "%s: %s: invalid argument for -%c\n", 15 myname, arg, opt); 16 exit(1); 17 } 18 return atoi(arg); 19 } 20 is_num_str(const char * str)21int is_num_str(const char *str) 22 { 23 while (*str) { 24 if (!isdigit(*str)) 25 return FALSE; 26 str++; 27 } 28 return TRUE; 29 } 30