View previous topic :: View next topic |
Author |
Message |
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
isdigit unexpected behavior |
Posted: Mon Sep 04, 2017 8:04 am |
|
|
I'm parsing a string separated by commas and some data is a float number but I don't need the decimal part so I'm filtering by using isdigit(x) function but that function return true when is a dot(.) and in the CCS help says:
isdigit(x) X is '0'..'9'
So there's any way to specify that only returns true to 0 to 9 ASCII codes? _________________ Electric Blue |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
|
Posted: Mon Sep 04, 2017 8:18 am |
|
|
Never mind, my mistake, bad pointer.
Code: | Dummy=(*Punt_GGA[8]+x);
if(isdigit(Dummy)) |
Corrected.
Code: | Dummy=(*(Punt_GGA[8]+x));
if(isdigit(Dummy)) |
_________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Mon Sep 04, 2017 8:21 am |
|
|
Yes. Use 'isamong'.
The 'isamong' command is the 'parent' of the others.
So:
Code: |
#define isdigitonly(x) isamong(x, "0123456789")
|
will give you a new operation 'isdigitonly', that behaves exactly like 'isdigit', except is only accepts the digit not the decimal.
isdigit, itself is only a similar macro expansion declared in ctype.h |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
|
Posted: Mon Sep 04, 2017 2:03 pm |
|
|
Thanks for your answer, I will take that in account. _________________ Electric Blue |
|
|
|