# TutorialTypes and their impact

#### Boboo99

##### Scrub
Dank Tier VIP
Fleep Tier Donator
Hey guys,
as I was talking with some guy in discord a few days ago, I kind of noticed that some people aren't quite trough the types of variables and their impact on the memory,that's what it should be about today.

First off all you should know each variable has a certain size, it might differ from compiler to compiler but in general:
 Type Size in bytes bool 1 char 1 short 2 int 4 float 4 long 4 double 8 long long 8

So the question is how can be this useful?

If you create structs which should be directly casted from the memory:
C++:
``````typedef struct someStruct
{
char pad0[4]; // 4 x 1 byte = 4 bytes
long long value; // 8 bytes
char pad1[12]; // 12 x 1 byte = 12 bytes
float vec[3]; //3 x 4byte = 12 bytes
int pad2[16]; //16 x 4 bytes = 64 bytes
};

someStruct* whatever = (someStruct*)(0xFFFFF);``````
So you can calculate the size of the struct and apply the right padding in it.

2.Getting the adresses of variables. Imagine after a loooong time of searching you finally found the offset for the y-coord in your game. Now you have to get the x-coords and the z-coords again.

We can do it easier, as we know the coordinates are mostly stored behind each other like this:

As we know the x,y,z are usually float and they have the size of 4 bytes, this would mean that x would have to be located at the position 4 bytes before y, because x takes up 4 bytes. Z would be located 4 bytes behind y because y is a float and it takes up 4 bytes too.

In our example:

We just saved the long work of finding 2 more adresses by just using our knowledge about the size of types

This should be everything for today

Good luck have fun and be 1337

#### Traxin

Escobar Tier VIP
Dank Tier Donator
Everybody NEEDS to know this stuff. Please...

Thanks for the write-up!

Attention! Before you post:

99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

• Fill out the form correctly
• Tell us the game name & coding language