Click here to Skip to main content
15,895,841 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
/* here nog and arrr on displaying shows the word ras but on compare return false result why???*/

Void ldata(unsigned char[])
{
// code for printing data on lcd
}

Char nog[]="ras";
Void rad (char arrr[])
{
For(g=0;g<strlen(arrr);g++)
{
Ldata(arrr[g]);
}
  For(g=0;g<strlen(nog);g++)
{
Ldata(nog[g]);
}
If(strcmp(arrr,nog)==0)
{
Led1=1;
}
}
Posted
Comments
jeron1 21-Aug-15 14:30pm    
Maybe add a null terminator in the arrr[] array after copying the characters. Not sure how this compiles, given the case issues (Char ?).

1 solution

If they contain exactly the same string, then strcmp returns 0 - so if your Led1 isn't getting a 1 then they clearly don't have the same value. A LCD display may not show that - the nog array will have four characters 'r', 'a', 's', and a null terminator - but we don't know what arrr contains. It could be as simple as the declaration
C++
char aaar[] = "ras ";
which would cause strcmp to fail, but wouldn't show anything odd on your display. You need to look more closely ate the actual values - perhaps by displaying the hex values instead of the characters themselves?

And next time you post code here, make sure it is exactly what you are executing - I know that isn't, because that won't compile as c is case sensitive, and if is not the same as If, for is not the same as For, and so on.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900