You are not comparing two "chars" but actually you are comparing pointer to char arrays, which are two completely different things. Since you are not using the std::string type (that supports comparison using the == operation), you have to understand how C strings work.
In fact, a and b are pointers to the first element of each respective array. Imagine that they do not contain a specific character but rather an address to the location where the first character of the array is located. If the address of a is "0000" and the address of b is "1000", then when you write a==b, you effectively compare the two addresses, which, as you can see, are different.
If you want to compare two C strings, use the strcmp() function that does the job for you:
Code:
char a[5] = "hola";
char b[5] = "hola";
if (strcmp(a,b) == 0)
{
cout << "Hello to you too\n";
}
else
{
cout << "No hello to you\n";
}
Since you are programming in C++, you could just write:
Code:
std::string a, b;
a = "hola";
b = "hola";
if(a == b) {
cout << "Hello to you too\n";
}
else {
cout << "No hello to you\n";
}
since then you're using the overloaded comparison operator of the string object.