better handling of float cli arguments

This commit is contained in:
2019-09-16 12:28:47 +02:00
parent b85b66caed
commit c3bc39750d
4 changed files with 39 additions and 8 deletions

View File

@@ -29,3 +29,16 @@ if (2 != foo) {
return 2;
}
/* --------------------------------------------------------------------- */
int parse_double(char *str, double *dptr)
{
double value;
int foo;
foo = sscanf(str, "%lf", &value);
if (1 == foo) {
*dptr = value;
return 1;
}
return -1;
}
/* --------------------------------------------------------------------- */