![]() |
![]() |
3407 | ![]() |
||||
![]() | |||||||
| Pointers | |||||||
A relational or equality operator has been applied to a string literal. A string literal is an object of type "array of char" and when used in an expression like this it is interpreted as a "pointer to char". A comparison between pointer values is probably not what was intended. If the intention was to perform a lexical comparison between 2 character strings, this is not the way to do it. For example:
/*PRQA S 2017,3122,3227,3408,3447,3625,3673 ++*/
int foo(char * pc)
{
int r = 0;
if (pc < "ABC") /* Messages 3407 and 490 */
{
r = 1;
}
if (pc == "ABC") /* Message 3407 */
{
r = 1;
}
return r;
}
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |