Part 44 – Pre-Decrement Operator

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/Reverse-Engineering-Tutorial

Let’s take a look at our pre-decrement operator example. The pre-decrement operator decrements a given value before the action gets assigned.

Let’s examine our code.

  1. #include <iostream>
  2. int main(void) {
  3. int myNumber = 16;
  4. int myNewNumber = --myNumber;
  5. std::cout << myNewNumber << std::endl;
  6. std::cout << myNumber << std::endl;
  7. return 0;
  8. }

Part 44 – Pre-Decrement Operator - 图1

As we compile and run we see 15 echoed out to the terminal.

Part 44 – Pre-Decrement Operator - 图2

The value of myNumber was 16 and when it is assigned with the pre-decrement operator we see that the new value is 15 as it is assigned into myNewNumber.

Next week we will dive into the Debuggin Pre-Decrement Operator.