A pointer points to an address of same type.
Yes, You read it right, Pointer points to an address of the same type that means if it is an int type it will point to int value similarly if it is a char type it will point to char value. This applied to pre-defined data types or user-defined data types.
//C/C++
#incude<iostream>
using namespace std;
int main(){
int a = 10; // integer variable
int * int_ptr = &a; // integer pointer points to integer type
char ch = 'A'; // Char variable
char * char_ptr = &ch; // char pointer points to character type
float fl = 0.5; // float variable
float * flt_ptr = &fl; // float pointer points to float type
return 0;
}
One thing you can notice is all pointer points to their type If you try to point to a different kind then you will get an error.
char_ptr = &a;
// error: cannot convert ‘int*’ to ‘char*’ in assignment
// char_ptr = &a;
Now the main question is how they work inside memory …

Each unit of memory has address ranging from 0x0000 0000 to 0xffff ffff [depends] . Each unit is used to store information and to get that information we need unit’s address . Basically using that address we perform memory read/write operation. Suppose if you have one Gb file stored at particular location ,instead of coping whole data and passing to sub program ,we can definitely say that take this memory address and go there and do whatever you want to do within 1Gb area and this is one way how pointer reduce space complexity, and execution time faster.
Overall you can say, Pointer points to an address, and using this address we can get data of its own type. In another way, by knowing the length of data you can do read/write operation in that memory region.

3 comments
[…] contains the memory address of another pointer and that pointer contains memory adders of a variable of its type. Let’s understand it via a scenario, There […]
LikeLike
Usually I do not read post on blogs, but I wish to say that this write-up very pressured me to check out and do it! Your writing style has been surprised me. Thanks, quite nice post.
LikeLiked by 1 person
[…] where they are declared. They can also be accessed outside the block if you know the exact memory address where it gets allotted in the stack. Their life is within the block where it is […]
LikeLiked by 1 person