CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

isdigit unexpected behavior

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

isdigit unexpected behavior
PostPosted: Mon Sep 04, 2017 8:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Sep 04, 2017 8:18 am     Reply with quote

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: 19359

View user's profile Send private message

PostPosted: Mon Sep 04, 2017 8:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Sep 04, 2017 2:03 pm     Reply with quote

Thanks for your answer, I will take that in account.
_________________
Electric Blue
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group