View previous topic :: View next topic |
Author |
Message |
noisette
Joined: 20 Dec 2007 Posts: 2
|
Using constant strings |
Posted: Thu Dec 20, 2007 8:35 am |
|
|
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
|
|
Posted: Thu Dec 20, 2007 9:55 am |
|
|
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
|
got it! |
Posted: Thu Dec 20, 2007 12:02 pm |
|
|
Thanks Ronald,
I finally used strcpy() to make a temporary RAM string and used it to do my strcmp.
Happy Holidays |
|
|
|