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

strcmp() and strcmpy() functions on PIC12F509

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







strcmp() and strcmpy() functions on PIC12F509
PostPosted: Tue Jul 24, 2007 6:35 am     Reply with quote

I'm trying to use two functions from string library.

strcmp() doesn't accept pointers to constant strings as an parameter
strcpy() accepts pointers to constant strings

Does anybody know the reason, both functions behave in a different ways?

There is information in CCS manual that CCS doesn't allow pointers to a constant to be used but why exception for strcpy()?

I'm using PCB V4.042 compiler.
Ttelmah
Guest







PostPosted: Tue Jul 24, 2007 8:08 am     Reply with quote

So you can use the strcpy function to copy the constant to RAM, and then use the other functions on it there.
The function is 'under the skin', overloaded, with two different functions present. The first is the normal 'string' pointer version, while the other treats the source as a function returning a byte from an indexed location. This code makes the function bulkier (which is why it is only in this one function), but then allows it to be used to make the other functions work.

Best Wishes
typek



Joined: 24 Jul 2007
Posts: 1

View user's profile Send private message

PostPosted: Tue Jul 24, 2007 3:27 pm     Reply with quote

I've made a mistake in the subject of the post. The name of the second function is of course strcpy() and not strcmpy() which was obviously noticed by you.

Your explanation sounds logical. The idea of having just one function which can operate on constants is a bit irritating in use though;) I'd prefer not to be forced to waste RAM just on the temporary buffer for keeping copies of the strings. At least I know now that the way it works is intentional.

Thanks
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