One of the most fundamentals in programming is understanding a pointer. It is confusing even for developers. You can also face it in some programming interview.
Let's get back in C. This old programming language is going to help us in understanding a pointer. I'm going to write some examples of it.
A pointer is a variable that stores an address of a variable in memory.
The code above is a general use of pointers. The result of a memory address could be different. You could try it here.
We can change the value of number because the variable of change_number contains the address of number.
String is an array of characters.
We just printed the characters or string by incrementing the pointer.
Reverse string. The most common question in the programming interview.
Linked List is a linear collection of data elements.
We built a struct to contain data of integer and a pointer to next struct.
That is how we built the linked list.
Count the length of the linked list. Almost similar to string.
Reverse Linked List. One of the most common questions in a programming interview about Linked List.
That is all I want to cover. A simple definition then followed by common examples. The most important is understanding how the pointer works.
To understand more is to practice more. There is a lot of common questions in the programming interview about pointer that I didn't cover here. Feel free to solve them.