Hello everyone, I'm new to the forum, to C++ and to programming in general.
I'm having a little problem with setting booleans to "true" or "false" as I please.
I was trying to write some pretty basic code, using "while" loops and booleans, when I noticed I had no control over the state of the booleans I created.
So I wrote the simplest code I could think of to test how booleans work.
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
usingnamespace std;
int main ()
{
bool k;
k = false;
if (k = true)
cout << "k is true";
else
cout << "k is false";
return 0;
}
It seems pretty straightforward right?
And yet, the string shown is always "k is true"!
I think I'm missing something about the way booleans are supposed to be used...