Part 35 – SizeOf 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

The next stage in our journey is that of the SizeOf operator. 

Let’s examine our code.

#include <iostream>

 

int main(void) {

            int myNumber = 16;

            int myNumberSize = sizeof(myNumber);

 

            std::cout << myNumberSize << std::endl;

 

            return 0;

}

To compile this we simply type:

g++ example8.cpp -o example8

./example8

We see 4 printed to the screen.

Let’s break it down:

We create a variable myNumber = 16 to which we create another variable myNumberSize which holds the value of the size of myNumber. We see that when we execute our code it shows 4 therefore we see that the SizeOf operator indicates an integer is 4 bytes wide.

Next week we will dive into Debugging SizeOf Operator.

results matching ""

    No results matching ""