OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
isValidInt.c
Go to the documentation of this file.
1 #include <genutils.h>
2 
3 #include <ctype.h>
4 
9 int isValidInt(const char* str) {
10 
11  // Handle leading sign character.
12  //
13  if (*str == '-')
14  str++;
15  else if (*str == '+')
16  str++;
17 
18  // Handle empty string or just "-" or "+"
19  //
20  if (!*str)
21  return 0;
22 
23  // Check for non-digit chars in the rest of the stirng.
24  //
25  while (*str) {
26  if (isdigit(*str))
27  str++;
28  else
29  return 0;
30  }
31 
32  return 1;
33 }
34 
int isValidInt(const char *str)
Definition: isValidInt.c:9
#define isdigit(c)
const char * str
Definition: l1c_msi.cpp:35