[SOLVED] String in Mikroc for pic

Status
Not open for further replies.

majeed1352

Newbie level 3
Joined
Oct 18, 2014
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
22
Hi,

I want to get a string from UART1 and analyse it with switch...case as follow:

char Comm[12];
.
.
if(Uart1_data_Readey()){
Uart1_read_text(Comm,".",255);
.
.
switch(Comm){
case "ON": .. .. .. ..; break;
case "OFF":.. .. .. ..; break;
.
.
default: Lcd_out_cp("BAD COMMAND";}


but the cumpiler says: " Operator " is not applicable to these operands"
What should I do to resolve it. Please guide me.

Thanks
 


Code C - [expand]
1
switch(Comm)

is causing the problem because you are testing for a string in switch which the C Compiler doesn't allow. Use strstr() or strcmp() to compare the received strings with strings stored in ROM. Search for CopyConst2Ram() function in mikroe forum and also use it with strstr() and strcmp().
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…