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

strtoul issue in stdlib.h

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



Joined: 23 Jan 2007
Posts: 8
Location: Corvallis, OR

View user's profile Send private message

strtoul issue in stdlib.h
PostPosted: Tue Jan 23, 2007 1:48 pm     Reply with quote

I have a project that utilizes an 18F8722. I'm using the strtoul function to parse through a space delimited series of parameters. In using this function, I believe I've discovered an issue.

My code is something like this:

char *params;

params = &something;
strtoul(params, &params, 10);


The issue is with the second argument to strtoul. It is supposed to give you an "end pointer" to where the strtoul parsing algorithm left off when it completed. I noticed, however, that my pointer would advance on return from strtoul like this:

0x01FE, 0x01FF, 0x0100......

instead of:

0x01FE, 0x01FF, 0x0200......

That's because the implementation of strtoul in stdlib.h casts the second parameter as type char. Since the endpointer parameter is essentially a pointer to a pointer, it should be cast to the data type required to store an address, not a 'char' data type. By modifying the strtoul library function to cast the second argument as an int16 throughout the function, everything then works just fine.
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