When comparing strings in C++, it is better to use "strcmp" instead of "==".
Your if statement should look like this:
if(strcmp(addr2,ipSrc) == 0 )
{
cout << "Equal\n";
}
else
{
cout << "Not equal\n";
}
Don't forget to include string at the top. ie:
#include>
"strcmp" returns an integral value indicating the relationship between the strings:
A zero value indicates that both strings are equal.
A value greater than zero indicates that the first character that does not match has a greater value in str1 than in str2; And a value less than zero indicates the opposite.
Check out this link[
]
I also suggest that you declare 'addr2' like this: char addr2[20]
Because, in your version, you are trying to convert a string constant to a character.