Which lines of code contain mistakes:
int main()
{
  int intvar;
  float flovar;
  int* intptr;
  float* floptr;
  void * voidptr;

  intptr=&intvar ; //1
  intptr=&flovar ; //2
  floptr =& intvar ;//3
  floptr =&flovar;  //4
  voidptr =& intvar; //5
  voidptr =&flovar ; //6
}
Explanation
A pointer is associated with a type (of the value it points to), which is specified during the declaration. A pointer can only hold an address of the declared type; it cannot hold an address of a different type.
However, a void pointer can hold the address of any data type (except function pointer).
Source: Pointer has a Type Too

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты