+ 5
[DUPLICATE] What are pointers used for
What are the practical uses of the pointer and when should I use them?
2 Answers
+ 5
Pointer are references to variable.
char *msg = "Hello world";
// this(msg) holds the reference (memory location) of char 'H'
You should use them when size of input is a variable, like names, messages, etc.
For example:
char *name;
// this pointer to variable "name" can hold large amount of characters