Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
'operator' : logical operation on address of string constant
Remarks
Using the operator with the address of a string literal produces unexpected code.
Example
The following example generates C4130:
// C4130.cpp
// compile with: /W4
int main()
{
char *pc;
pc = "Hello";
if (pc == "Hello") // C4130
{
}
}
The if statement compares the value stored in the pointer pc to the address of the string "Hello", which is allocated separately each time the string occurs in code. The if statement does not compare the string pointed to by pc with the string "Hello".
To compare strings, use the strcmp function.