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

atoi() question

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



Joined: 08 Sep 2003
Posts: 197
Location: Omaha NE USA

View user's profile Send private message Send e-mail Visit poster's website

atoi() question
PostPosted: Fri May 08, 2009 12:56 pm     Reply with quote

From the CCS C manual:

Quote:
Converts the string passed to the function into an int representation. Accepts both decimal and hexadecimal argument.


It seems to work fine with decimal strings, but not hex. If I give it a string containing hex digits (like FF) it returns 0. Anyone know any different?
Steve H
Guest







PostPosted: Fri May 08, 2009 1:32 pm     Reply with quote

The function is 'inspectable' look at the include header file.

As I recall the HEX has to be in C notation.

e.g. :

"5F" will not work

"0x5F" will work

HTH - Steve H.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 08, 2009 1:53 pm     Reply with quote

Or make a version of atoi that only processes hex chars: axtoi()
http://www.ccsinfo.com/forum/viewtopic.php?t=35175&start=2
Guest








PostPosted: Mon May 11, 2009 1:17 pm     Reply with quote

Oh wow - I went looking for atoi() myself today for another project and only the prototype is on the stdlib.h file now (V4.xxx) - the full function used to be in version 3x.

I thought I was losing my mind - as I could remember seeing it!

No matter - just google atoi() and you will find out how it is done or to use as a base for your own function as PCM suggested....

It is a typical C function - very compact and efficient....

Steve H.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 11, 2009 1:40 pm     Reply with quote

Quote:
only the prototype is on the stdlib.h file now (V4.xxx)

I looked in stdlib.h in vs. 4.092 and the full source is in there.
It starts at line 429. It looks like this:
Code:
signed int atoi(char *s)
{
   signed int result;
   unsigned int sign, base, index;
   char c;
Guest








PostPosted: Mon May 11, 2009 10:04 pm     Reply with quote

Oh - so I am loosing my mind! I just needed to look farther down! You are right the atoi() source is still 'Inspectale'

:-)

Thanks for pointing that out...

Steve H.
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