Q:

Write code to change the value of a pointer. Write code to change the value to which the pointer points

0

Write code to change the value of a pointer. Write code to change the value to which the pointer points.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>

int main() {
  int i;
  int *ip = &i;

  *ip = 10;
  std::cout << i << " " << *ip << std::endl;  // 10 10
  i = 5;
  std::cout << i << " " << *ip << std::endl;  // 5 5

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now