Dec 24 2012, 03:35 PM
There's a couple of reasons.
You can pass pointers around to functions and methods to work on variables by reference instead of by value so changing anything at that pointer will change the value of the variable you passed outside the function too.
Another thing you can do with pointers is change it's data type. For instance if you're working with network data you'll typically read the data into a byte array then change that byte array into a struct so you can start using the data how it's meant to be used. The byte array data type can't be recast into a struct, that's why you have pointers, you take the raw data in memory and say "this raw data is a struct".
You can pass pointers around to functions and methods to work on variables by reference instead of by value so changing anything at that pointer will change the value of the variable you passed outside the function too.
Another thing you can do with pointers is change it's data type. For instance if you're working with network data you'll typically read the data into a byte array then change that byte array into a struct so you can start using the data how it's meant to be used. The byte array data type can't be recast into a struct, that's why you have pointers, you take the raw data in memory and say "this raw data is a struct".


![[-]](https://war-lords.net/forum/images/collapse.png)