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

Using constant strings

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



Joined: 20 Dec 2007
Posts: 2

View user's profile Send private message

Using constant strings
PostPosted: Thu Dec 20, 2007 8:35 am     Reply with quote

I am trying to compare a four character string that comes into a array of character called 'keybuffer' against five possible constant string combinations in 'keysequences'. I always get the message: Attempt to create a pointer to a constant. I am not too familiar with constant strings manipulations.

How would I go about comparing the value in keybuffer against multiple constant strings stored in keysequences?

Code:

char keybuffer[4];
const char keysequences[][*]={"BCDA","CDAB","AAAA","ACCC","DACC"};


if(strcmp(keybuffer,keysequences[2])==0)
                  printf(lcd_putc,"\f%S",MENUMSG[2]);  // print key sequence is a Match!



We have the 4.063 version of the PCWH compiler

Thanks for your help
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu Dec 20, 2007 9:55 am     Reply with quote

I only have version 3.249 (haven't wanted to pay for a beta compiler) but the help file states:

Quote:
cresult=strcmp (s1, s2)

Note that s1 and s2 MAY NOT BE A CONSTANT (like "hi").


This might be your problem.

Ronald
noisette



Joined: 20 Dec 2007
Posts: 2

View user's profile Send private message

got it!
PostPosted: Thu Dec 20, 2007 12:02 pm     Reply with quote

Thanks Ronald,

I finally used strcpy() to make a temporary RAM string and used it to do my strcmp.

Happy Holidays
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