Q:

Storing Address of a character to an Integer Pointer

As we know that the task of a pointer (In C++) is to store an address. The size of address depends on the computer architecture .
For this example let us assume that we have a 32-bit machine and the size of address is 4-Byte  . Now if we create an Integer pointer
int x=20;
int * ptr;
ptr = &x;    //  This is fine the address of x is of 4-Bytes

Similarly if we have a character c
char c='a';
ptr = &c;      // This puts an error although address size of &c is still 4-Byte.

The task of the pointer is to store an address then why ptr do not store the address of a character. Although the address for both the integer and a character is of 4-Bytes.There is no datatype of address then should it not save the address in ptr (pointer) ?

A:

The issue is not that the pointer variable is the wrong size. The issue is one of type safety. You are declaring that the pointer variable contains the address of an int. Which means that when you try to pass the address of a char, the compiler complains. It says, "you promised to give me the address of an int, but that is the address of a char". 
The compiler is not trying to protect you against problems with storing the address. As you note, there are none. The problem that the compiler is protecting you from is that which arises when you de-reference the address. 

