+ 3

what exactly does a pointer do?

28th Jun 2016, 4:48 PM
Bounty Hunter
Bounty Hunter - avatar
2 Answers
+ 7
A pointer is a variable that holds an address of another variable, it helps us to point to that address whenever it's needed all along the code
28th Jun 2016, 5:15 PM
Hicham Mine
Hicham Mine - avatar
+ 1
A pointer does not have to point to a variable. It can just point to *any* address in memory without having to point to a variable you allocated before. This way you can write and read in arbitrary memory. This is usually often used, if you program without an operating system. Operating systems might prevent arbitrary access to memory aka "memory access violation" on Windows or "segmentation fault" on Linux :-)
29th Jun 2016, 1:30 AM
Stefan
Stefan - avatar