Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Explain C Pointers
#3
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".

Messages In This Thread
Explain C Pointers - by Danger255 - Dec 09 2012, 03:01 AM
RE: Explain C Pointers - by Dr. gkovr - Dec 09 2012, 03:20 AM
RE: Explain C Pointers - by Leaky - Dec 24 2012, 03:35 PM
RE: Explain C Pointers - by Danger255 - Dec 24 2012, 03:45 PM
RE: Explain C Pointers - by Pishtim - Nov 26 2013, 04:39 AM
RE: Explain C Pointers - by Spartacus - Nov 26 2013, 05:00 AM
RE: Explain C Pointers - by Pishtim - Nov 26 2013, 05:18 AM

Users browsing this thread: 1 Guest(s)