Why are there different types of pointers for different data types in C?

前端 未结 7 1306
难免孤独
难免孤独 2020-12-03 15:08

If we have to hold an address of any data type then we require a pointer of that data type.

But a pointer is simply an address, and an address is always int

7条回答
  •  独厮守ぢ
    2020-12-03 15:37

    Because the type of a pointer tells the compiler that at a time on how many bytes you can perform the operation.

    Example: in case of char, only one byte. And it may be different in case of int of two bytes.

提交回复
热议问题