Part 12 - Boolean Primitive Datatype

For a complete table of contents of all the lessons please click below as it will give you a brief of each lesson in addition to the topics it will cover. https://github.com/mytechnotalent/hacking\_c-\_arm64

Today we are going to talk about the C++ boolean datatype that stores either a 0 or 1 to represent 0 for false _and _1 for anything true.

This kind of flag is used extensively in programming in general and we will look at another very basic program to understand its simple usage.

  1. #include <iostream>
  2. int main()
  3. {
  4. bool my_bool = true;
  5. std::cout << my_bool << std::endl;
  6. return 0;
  7. }

We see that we are creating a bool and assigning it a _true _value or _1 _value and printing it.

Let’s compile and link.

  1. g++ -o 0x04_asm64_boolean_primitive_datatype 0x04_asm64_boolean_primitive_datatype.cpp

Let’s run.

  1. ./0x04_asm64_boolean_primitive_datatype

We simply see the following.

  1. 1

It successfully echoed 1 to the terminal stdout. Very simple.

Next week we will debug this very simple example.