Why is the data type needed in pointer declarations?

前端 未结 8 663
萌比男神i
萌比男神i 2020-12-04 22:07

As far as I know about data types in C/C++, while declaring a variable, we need to declare its data type, which tells the compiler to reserve the number of bytes in the memo

8条回答
  •  自闭症患者
    2020-12-04 22:32

    The Data type is needed when dereferencing the pointer so it knows how much data it should read. For example dereferencing a char pointer should read the next byte from the adress it is pointing to while an int pointer should read 2 bytes.

提交回复
热议问题