Another way to do it would be:
int main() {
bool bacon = true;
if (bacon == true)
{
printf("this worked?");
}
}
or:
int main() {
bool bacon = true;
if (bacon != false)
{
printf("this worked?");
}
}
or:
int main() {
bool bacon = true;
if (bacon != 0)
{
printf("this worked?");
}
}
or:
int main() {
bool bacon = true;
if (!bacon == false)
{
printf("this worked?");
}
}
or:
int main() {
bool bacon = true;
if (!bacon == false)
{
printf("this worked?");
}
}
or:
#include <iostream>
int main() {
bool bacon = true;
if (bacon)
{
std::cout << "this worked?";
}
}
Hopefully, that will give you enough different ways to think about :). By the way, be very careful not to use a single = for comparing things!
Also, you probably should spend at least an hour or two trying to figure things out on your own before you post here because people tend to get overly aggravated about helping people they have personally decided haven’t put their own work into the problem. For the same reason, you should give as much information as possible about what you have tried already, which also helps speed up the process of having your question answered.
1
solved How do you check if the bool variable is true? [closed]