Toggle navigation
Ocean Color Science Software
Jump to content
ocssw
V2022
web
ocssw
ocssw_src
oel_util
libgenutils
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
genutils.h
isValidInt
int isValidInt(const char *str)
Definition:
isValidInt.c:9
isdigit
#define isdigit(c)
Definition:
parse_file_name.c:7
str
const char * str
Definition:
l1c_msi.cpp:35