#include <iostream>
#include <string>
usingnamespace std;
int main()
{
bool t[] = {false, true, false & true};
string u[2] = {"false", "true"};
bool *p;
p = t + 2; //
cout << u[*p]; // so this part is really 2nd part of the string u? then why is the output false, rather than true?
return 0;
}
What makes it that the output is false on my code? I just don't understand anything.
On line 6, false & true means "false and true", which evaluates to false
for the array t, and the pointer *p, p=t means that p is pointing to t[0]. Pointer arithmetic says that p+1 points to t[1], p+2 points to t[2]. Your t array has t[0]=false, t[1]=true, and as it was pointed before t[2]=false